Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): Add check for both serverURL and localURL in navigation #5736

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ios/Capacitor/Capacitor/WebViewDelegationHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ internal class WebViewDelegationHandler: NSObject, WKNavigationDelegate, WKUIDel

// otherwise, is this a new window or a main frame navigation but to an outside source
let toplevelNavigation = (navigationAction.targetFrame == nil || navigationAction.targetFrame?.isMainFrame == true)
if navURL.absoluteString.contains(bridge.config.serverURL.absoluteString) == false, toplevelNavigation {

// Check if the url being navigated to is configured as an application url (whether local or remote)
let isApplicationNavigation = navURL.absoluteString.starts(with: bridge.config.serverURL.absoluteString) ||
navURL.absoluteString.starts(with: bridge.config.localURL.absoluteString)

if !isApplicationNavigation, toplevelNavigation {
// disallow and let the system handle it
if UIApplication.shared.applicationState == .active {
UIApplication.shared.open(navURL, options: [:], completionHandler: nil)
Expand Down