Skip to content

Commit bb3a837

Browse files
authored
Merge pull request #514 from funnel20/WebViewController
Always allow Navigation Action for http/https URL scheme to prevent u…
2 parents f1f30b1 + a5bcd51 commit bb3a837

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Sources/InAppSettingsKit/Controllers/IASKAppSettingsWebViewController.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,19 +326,20 @@ - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigat
326326
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler NS_EXTENSION_UNAVAILABLE("Uses APIs (i.e UIApplication.sharedApplication) not available for use in App Extensions.") {
327327
NSURL* newURL = navigationAction.request.URL;
328328

329-
// intercept mailto URL and send it to an in-app Mail compose view instead
330-
if ([[newURL scheme] isEqualToString:@"mailto"]) {
329+
// Intercept mailto URL scheme and send it to an in-app Mail compose view instead:
330+
if ([newURL.scheme isEqualToString:@"mailto"]) {
331331
[self handleMailto:newURL];
332332
decisionHandler(WKNavigationActionPolicyCancel);
333333
return;
334334
}
335335

336-
// open inline if host is the same, otherwise, pass to the system
337-
if (![newURL host] || ![self.url host] || [[newURL host] isEqualToString:(NSString *)[self.url host]]) {
336+
// Allow loading of any http(s) requests:
337+
if ([newURL.scheme isEqualToString:@"http"] || [newURL.scheme isEqualToString:@"https"]) {
338338
decisionHandler(WKNavigationActionPolicyAllow);
339339
return;
340340
}
341341

342+
// For any other URL scheme, let the system find an appropriate app to open the URL:
342343
[UIApplication.sharedApplication openURL:newURL
343344
options:@{}
344345
completionHandler:nil];

0 commit comments

Comments
 (0)