From f94e38f5c3c70125b7cee85e6115893a2c229231 Mon Sep 17 00:00:00 2001 From: yichengchen Date: Mon, 29 Jul 2019 12:03:11 +0800 Subject: [PATCH] Improve: support url scheme clash, and remove additional / in the url path --- ClashX/AppDelegate.swift | 11 ++++++----- ClashX/Info.plist | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ClashX/AppDelegate.swift b/ClashX/AppDelegate.swift index 910d0bb..3cf0160 100644 --- a/ClashX/AppDelegate.swift +++ b/ClashX/AppDelegate.swift @@ -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() { diff --git a/ClashX/Info.plist b/ClashX/Info.plist index 9b9a471..dbc7306 100644 --- a/ClashX/Info.plist +++ b/ClashX/Info.plist @@ -23,6 +23,8 @@ CFBundleTypeRole Editor + CFBundleURLIconFile + Icon CFBundleURLName com.west2online.ClashX CFBundleURLSchemes @@ -30,6 +32,18 @@ clashx + + CFBundleTypeRole + Editor + CFBundleURLIconFile + Icon + CFBundleURLName + com.west2online.Clash + CFBundleURLSchemes + + clash + + CFBundleVersion 1.10.1