Allow navigating to the same url with a different fragment

This commit is contained in:
Shadowfacts 2022-01-15 15:13:16 -05:00
parent 36fda4d51f
commit 1726a7c711
1 changed files with 7 additions and 0 deletions

View File

@ -163,6 +163,13 @@ extension ReadViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy { func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy {
if navigationAction.navigationType == .linkActivated { if navigationAction.navigationType == .linkActivated {
let url = navigationAction.request.url! let url = navigationAction.request.url!
if url.fragment != nil {
var components = URLComponents(url: url, resolvingAgainstBaseURL: false)!
components.fragment = nil
if components.url == item.url {
return .allow
}
}
present(createSafariVC(url: url), animated: true) present(createSafariVC(url: url), animated: true)
return .cancel return .cancel
} else { } else {