diff --git a/ios/Capacitor/Capacitor/CAPInstanceConfiguration.swift b/ios/Capacitor/Capacitor/CAPInstanceConfiguration.swift index fe7121c881..3578363b57 100644 --- a/ios/Capacitor/Capacitor/CAPInstanceConfiguration.swift +++ b/ios/Capacitor/Capacitor/CAPInstanceConfiguration.swift @@ -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) } diff --git a/ios/Capacitor/CapacitorTests/ConfigurationTests.swift b/ios/Capacitor/CapacitorTests/ConfigurationTests.swift index 6e96272f87..4b5057f9b8 100644 --- a/ios/Capacitor/CapacitorTests/ConfigurationTests.swift +++ b/ios/Capacitor/CapacitorTests/ConfigurationTests.swift @@ -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")) diff --git a/ios/Capacitor/TestsHostApp/configurations/server.json b/ios/Capacitor/TestsHostApp/configurations/server.json index 953db184e7..56a8f53445 100644 --- a/ios/Capacitor/TestsHostApp/configurations/server.json +++ b/ios/Capacitor/TestsHostApp/configurations/server.json @@ -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" },