This commit is contained in:
Brent Simmons 2021-09-05 12:37:33 -07:00
commit 398d617bb7
3 changed files with 28 additions and 13 deletions

View File

@ -43,7 +43,17 @@ struct Browser {
/// - Note: Some browsers (specifically Chromium-derived ones) will ignore the request
/// to open in the background.
static func open(_ urlString: String, inBackground: Bool) {
if let url = URL(unicodeString: urlString) {
guard let url = URL(unicodeString: urlString), let preparedURL = url.preparedForOpeningInBrowser() else { return }
let configuration = NSWorkspace.OpenConfiguration()
configuration.requiresUniversalLinks = true
configuration.promptsUserIfNeeded = false
if inBackground {
configuration.activates = false
}
NSWorkspace.shared.open(preparedURL, configuration: configuration) { (runningApplication, error) in
guard error != nil else { return }
if let defaultBrowser = defaultBrowser {
defaultBrowser.openURL(url, inBackground: inBackground)
} else {

View File

@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/Thomvis/BrightFutures.git",
"state": {
"branch": null,
"revision": "9279defa6bdc21501ce740266e5a14d0119ddc63",
"version": "8.0.1"
"revision": "939858b811026f85e87847a808f0bea2f187e5c4",
"version": "8.1.0"
}
},
{
@ -33,8 +33,8 @@
"repositoryURL": "https://github.com/tid-kijyun/Kanna.git",
"state": {
"branch": null,
"revision": "c657fb9f5827ef138068215c76ad0bb62bbc92da",
"version": "5.2.4"
"revision": "f9e4922223dd0d3dfbf02ca70812cf5531fc0593",
"version": "5.2.7"
}
},
{
@ -51,8 +51,8 @@
"repositoryURL": "https://github.com/microsoft/plcrashreporter.git",
"state": {
"branch": null,
"revision": "de6b8f9db4b2a0aa859a5507550a70548e4da936",
"version": "1.8.1"
"revision": "d747ab5de269cd44022bbe96ff9609d8626694ab",
"version": "1.9.0"
}
},
{
@ -60,8 +60,8 @@
"repositoryURL": "https://github.com/Ranchero-Software/RSCore.git",
"state": {
"branch": null,
"revision": "2a13519b4d91843faa6aff4245b0e387dc64eafe",
"version": "1.0.6"
"revision": "060b12a3d3b6d27d57b2fae84160bfec91ec7118",
"version": "1.0.7"
}
},
{
@ -96,8 +96,8 @@
"repositoryURL": "https://github.com/Ranchero-Software/RSWeb.git",
"state": {
"branch": null,
"revision": "2f9ad98736c5c17dfb2be0b3cc06e71a49b061fa",
"version": "1.0.1"
"revision": "2f7849a9ad2cb461b3d6c9c920e163596e6b5d7b",
"version": "1.0.3"
}
},
{

View File

@ -351,8 +351,13 @@ extension WebViewController: WKNavigationDelegate {
if AppDefaults.shared.useSystemBrowser {
UIApplication.shared.open(url, options: [:])
} else {
let vc = SFSafariViewController(url: url)
self.present(vc, animated: true, completion: nil)
UIApplication.shared.open(url, options: [.universalLinksOnly: true]) { didOpen in
guard didOpen == false else {
return
}
let vc = SFSafariViewController(url: url)
self.present(vc, animated: true)
}
}
} else if components?.scheme == "mailto" {