Add fallback for opening non-Gemini/HTTP URLs
This commit is contained in:
parent
d4af73a18e
commit
92fe14cd9b
|
@ -99,7 +99,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
extension SceneDelegate: NavigationManagerDelegate {
|
extension SceneDelegate: NavigationManagerDelegate {
|
||||||
func loadNonGeminiURL(_ url: URL) {
|
func loadNonGeminiURL(_ url: URL) {
|
||||||
UIApplication.shared.open(url, options: [.universalLinksOnly: true]) { (success) in
|
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 {
|
if Preferences.shared.useInAppSafari {
|
||||||
let config = SFSafariViewController.Configuration()
|
let config = SFSafariViewController.Configuration()
|
||||||
config.entersReaderIfAvailable = Preferences.shared.useReaderMode
|
config.entersReaderIfAvailable = Preferences.shared.useReaderMode
|
||||||
|
@ -108,6 +109,13 @@ extension SceneDelegate: NavigationManagerDelegate {
|
||||||
} else {
|
} else {
|
||||||
UIApplication.shared.open(url, options: [:])
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue