Skip to content

Commit

Permalink
fix(ios): proper handling of allowNavigation with multiple wildcard (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
macdja38 authored Oct 11, 2021
1 parent e238233 commit cda17a6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ios/Capacitor/Capacitor/CAPInstanceConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extension InstanceConfiguration {
return false
}
// remove any wildcard segments
for wildcard in patternComponents.enumerated().filter({ $0.element == "*" }) {
for wildcard in patternComponents.enumerated().reversed().filter({ $0.element == "*" }) {
hostComponents.remove(at: wildcard.offset)
patternComponents.remove(at: wildcard.offset)
}
Expand Down
2 changes: 2 additions & 0 deletions ios/Capacitor/CapacitorTests/ConfigurationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ class ConfigurationTests: XCTestCase {
XCTAssertTrue(configuration.shouldAllowNavigation(to: "test.capacitorjs.com"))
XCTAssertTrue(configuration.shouldAllowNavigation(to: "192.168.0.1"))
XCTAssertTrue(configuration.shouldAllowNavigation(to: "subdomain.test.ionicframework.com"))
XCTAssertTrue(configuration.shouldAllowNavigation(to: "wildcard1.wildcard2.example.com"))
XCTAssertFalse(configuration.shouldAllowNavigation(to: "wildcard1.example.com"))
XCTAssertFalse(configuration.shouldAllowNavigation(to: "google.com"))
XCTAssertFalse(configuration.shouldAllowNavigation(to: "192.168.0.2"))
XCTAssertFalse(configuration.shouldAllowNavigation(to: "ionicframework.com"))
Expand Down
2 changes: 1 addition & 1 deletion ios/Capacitor/TestsHostApp/configurations/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"loggingBehavior": "production",
"server": {
"iosScheme": "override",
"allowNavigation": ["*.capacitorjs.com", "ionic.io", "192.168.0.1", "subdomain.*.ionicframework.com"],
"allowNavigation": ["*.capacitorjs.com", "ionic.io", "192.168.0.1", "subdomain.*.ionicframework.com", "*.*.example.com"],
"hostname": "myhost",
"url": "http://192.168.100.1:2057"
},
Expand Down

0 comments on commit cda17a6

Please sign in to comment.