From 530051386fab59dbb6e55a80471909cecc1498b3 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 1 Sep 2021 20:38:50 -0500 Subject: [PATCH] Fix regression that prevented universal links from working --- Mac/Browser.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Mac/Browser.swift b/Mac/Browser.swift index 5f8b7a0ee..d574bc7ad 100644 --- a/Mac/Browser.swift +++ b/Mac/Browser.swift @@ -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 {