Improve: support url scheme clash, and remove additional / in the url path
This commit is contained in:
parent
3d209e0251
commit
f94e38f5c3
@ -101,11 +101,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
guard let components = URLComponents(string: url.absoluteString),
|
||||
let scheme = components.scheme,
|
||||
scheme == "clashx"
|
||||
scheme.hasPrefix("clash")
|
||||
else {return}
|
||||
|
||||
switch components.path {
|
||||
case "/install-config":
|
||||
if components.path.hasSuffix("install-config") {
|
||||
guard let url = components.queryItems?.first(where: { item in
|
||||
item.name == "url"
|
||||
})?.value else {return}
|
||||
@ -115,9 +114,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
||||
NotificationCenter.default.post(name: Notification.Name(rawValue: "didGetUrl"), object: nil, userInfo: ["url":url])
|
||||
}
|
||||
default:
|
||||
Logger.log(msg: "unknown url path:\(components.path)")
|
||||
|
||||
} else {
|
||||
Logger.log(msg: "Unknown url path:\(components.path)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func setupData() {
|
||||
|
@ -23,6 +23,8 @@
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>CFBundleURLIconFile</key>
|
||||
<string>Icon</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.west2online.ClashX</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
@ -30,6 +32,18 @@
|
||||
<string>clashx</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>CFBundleURLIconFile</key>
|
||||
<string>Icon</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.west2online.Clash</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>clash</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.10.1</string>
|
||||
|
Loading…
Reference in New Issue
Block a user