Add fallback for opening non-Gemini/HTTP URLs

This commit is contained in:
Shadowfacts 2020-12-20 15:08:00 -05:00
parent d4af73a18e
commit 92fe14cd9b
1 changed files with 9 additions and 1 deletions

View File

@ -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)
}
}
}