Skip to content

Commit

Permalink
Bug 1315759 - Don't try loading unsupported URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
thebnich committed Nov 8, 2016
1 parent 038cec9 commit 82f3e4c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Blockzilla/Browser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ class Browser: NSObject {
}

extension Browser: UIWebViewDelegate {
private static let supportedSchemes = ["http", "https", "about"]

func webViewDidStartLoad(_ webView: UIWebView) {
if estimatedProgress == 0 {
estimatedProgress = 0.1
Expand All @@ -138,6 +140,9 @@ extension Browser: UIWebViewDelegate {
}

func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
// We don't currently support opening in external apps, so just ignore unsupported schemes.
guard let scheme = request.url?.scheme, Browser.supportedSchemes.contains(scheme.lowercased()) else { return false }

if request.mainDocumentURL != url {
url = request.mainDocumentURL
}
Expand Down

0 comments on commit 82f3e4c

Please sign in to comment.