Merge pull request #27 from igtm/encodeurl

[fix] encode resourceURL
This commit is contained in:
Lorenzo Pichilli 2018-12-20 09:20:16 +01:00 committed by GitHub
commit 3b538104f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -746,7 +746,9 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
}
else if message.name == "resourceLoaded" && (webViewOptions?.useOnLoadResource)! {
if let resource = convertToDictionary(text: message.body as! String) {
let url = URL(string: resource["name"] as! String)!
let rawUrl = resource["name"] as! String
let encodedUrl = rawUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
let url = URL(string: encodedUrl)!
if !UIApplication.shared.canOpenURL(url) {
return
}