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),
|
guard let components = URLComponents(string: url.absoluteString),
|
||||||
let scheme = components.scheme,
|
let scheme = components.scheme,
|
||||||
scheme == "clashx"
|
scheme.hasPrefix("clash")
|
||||||
else {return}
|
else {return}
|
||||||
|
|
||||||
switch components.path {
|
if components.path.hasSuffix("install-config") {
|
||||||
case "/install-config":
|
|
||||||
guard let url = components.queryItems?.first(where: { item in
|
guard let url = components.queryItems?.first(where: { item in
|
||||||
item.name == "url"
|
item.name == "url"
|
||||||
})?.value else {return}
|
})?.value else {return}
|
||||||
@ -115,9 +114,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
||||||
NotificationCenter.default.post(name: Notification.Name(rawValue: "didGetUrl"), object: nil, userInfo: ["url":url])
|
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() {
|
func setupData() {
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>Editor</string>
|
<string>Editor</string>
|
||||||
|
<key>CFBundleURLIconFile</key>
|
||||||
|
<string>Icon</string>
|
||||||
<key>CFBundleURLName</key>
|
<key>CFBundleURLName</key>
|
||||||
<string>com.west2online.ClashX</string>
|
<string>com.west2online.ClashX</string>
|
||||||
<key>CFBundleURLSchemes</key>
|
<key>CFBundleURLSchemes</key>
|
||||||
@ -30,6 +32,18 @@
|
|||||||
<string>clashx</string>
|
<string>clashx</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</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>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.10.1</string>
|
<string>1.10.1</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user