From 66fc258e0cf006e2c5e7e128d0311d1b126c32b6 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Tue, 6 Dec 2022 10:58:01 +0800 Subject: [PATCH] Dont crash if clicking on a fragment link If a user clicks on a fragment link like click here to skip to info we would previously crash because we would reload the bundle. This prevents the crash but the link does not work, we can't just synthesize these links with JS, because the id="info" items are usually removed by readability. To properly handle this, we probably need to preserve some id elements if they are linked to. Then we can scroll to those elements in Javascript. --- .../Sources/App/Views/WebReader/WebReaderCoordinator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift index 99e9952d3..cffc3a7df 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderCoordinator.swift @@ -62,7 +62,7 @@ extension WebReaderCoordinator: WKNavigationDelegate { // swiftlint:disable:next line_length func webView(_: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { if navigationAction.navigationType == .linkActivated { - if let linkURL = navigationAction.request.url { + if let linkURL = navigationAction.request.url, !linkURL.isFileURL { linkHandler(linkURL) } decisionHandler(.cancel)