From 81518a3f0012ded8969cebbccb819c8b0fd9b79a Mon Sep 17 00:00:00 2001 From: pavel-cliqz <48993523+pavel-cliqz@users.noreply.github.com> Date: Thu, 1 Aug 2019 12:15:05 +0200 Subject: [PATCH] Fixed ome search results not opening issue (#415) --- Cliqz/Search/CliqzSearchViewController.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Cliqz/Search/CliqzSearchViewController.swift b/Cliqz/Search/CliqzSearchViewController.swift index c69579160..926b90c2d 100644 --- a/Cliqz/Search/CliqzSearchViewController.swift +++ b/Cliqz/Search/CliqzSearchViewController.swift @@ -251,7 +251,20 @@ class CliqzSearchViewController : UIViewController, KeyboardHelperDelegate, UIAl extension CliqzSearchViewController { @objc func didSelectUrl(_ notification: Notification) { - if let url_str = notification.object as? NSString, let url = URL(string: url_str as String) { + // ReactNative is not sending encoded URL always, so for that we should have fall back mechanism + guard let url_str = notification.object as? String else { + return + } + var url: URL? + + if let selectedUrl = URL(string: url_str) { + url = selectedUrl + } else if let encodedString = url_str.addingPercentEncoding( + withAllowedCharacters: NSCharacterSet.urlFragmentAllowed) { + url = URL(string: encodedString) + } + + if let url = url { #if PAID let isSearchEngine = notification.userInfo?[OpenURLIsSearchEngineKey] as? Bool if UserPreferences.instance.shouldShowNonPrivateSearchWarningMessage, isSearchEngine ?? false {