Merge pull request #4022 from keymanapp/fix/ios/package-links-are-internal

fix(ios): package-internal links should be considered internal
This commit is contained in:
Joshua Horton 2020-12-01 15:16:48 +07:00 committed by GitHub
commit d0313e8337
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -90,7 +90,12 @@ class PackageWebViewController: UIViewController, WKNavigationDelegate {
decidePolicyFor navigationAction: WKNavigationAction,
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if let link = navigationAction.request.url {
if UniversalLinks.isExternalLink(link) {
if link.path.hasPrefix(self.package.sourceFolder.path) {
// Links from within the package will show up as 'external' in the condition below!
// So, we check against package-internal links first.
decisionHandler(.allow)
return
} else if UniversalLinks.isExternalLink(link) {
decisionHandler(.cancel)
// Kick this link out to an external Safari process.