From 92fe14cd9bc9bbfb3d87942401735998b5b41f8b Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 20 Dec 2020 15:08:00 -0500 Subject: [PATCH] Add fallback for opening non-Gemini/HTTP URLs --- Gemini-iOS/SceneDelegate.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Gemini-iOS/SceneDelegate.swift b/Gemini-iOS/SceneDelegate.swift index 356a692..95fb111 100644 --- a/Gemini-iOS/SceneDelegate.swift +++ b/Gemini-iOS/SceneDelegate.swift @@ -99,7 +99,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { extension SceneDelegate: NavigationManagerDelegate { func loadNonGeminiURL(_ url: URL) { UIApplication.shared.open(url, options: [.universalLinksOnly: true]) { (success) in - if !success { + guard !success else { return } + if url.scheme == "http" || url.scheme == "https" { if Preferences.shared.useInAppSafari { let config = SFSafariViewController.Configuration() config.entersReaderIfAvailable = Preferences.shared.useReaderMode @@ -108,6 +109,13 @@ extension SceneDelegate: NavigationManagerDelegate { } else { UIApplication.shared.open(url, options: [:]) } + } else { + let alert = UIAlertController(title: "Cannot open '\(url.scheme!)' URL", message: url.absoluteString, preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "Copy URL", style: .default, handler: { (_) in + UIPasteboard.general.setObjects([url]) + })) + alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil)) + self.window!.rootViewController!.present(alert, animated: true) } } }