Improve: support url scheme clash, and remove additional / in the url path

This commit is contained in:
yichengchen 2019-07-29 12:03:11 +08:00
parent 3d209e0251
commit f94e38f5c3
2 changed files with 20 additions and 5 deletions

View File

@ -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() {

View File

@ -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>