Fix regression that prevented universal links from working

This commit is contained in:
Maurice Parker 2021-09-01 20:38:50 -05:00
parent ec6cb1a1b1
commit 530051386f
1 changed files with 11 additions and 1 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 {