Issue #365

import WebKit
import SafariServices

final class WebViewHandler: NSObject, WKNavigationDelegate {
    var show: ((UIViewController) -> Void)?
    let supportedSchemes = ["http", "https"]

    func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
        defer {
            decisionHandler(.allow)
        }

        guard
            navigationAction.navigationType == .linkActivated,
            let url = navigationAction.request.url,
            let scheme = url.scheme,
            supportedSchemes.contains(scheme)
        else {
            return
        }

        let controller = SFSafariViewController(url: url)
        show?(controller)
    }
}