Fixes bug when decode SIP002 URL with plugin but plugin opts is empty string.
This commit is contained in:
@ -137,6 +137,8 @@ class ServerProfile: NSObject, NSCopying {
|
|||||||
if parts.count == 2 {
|
if parts.count == 2 {
|
||||||
plugin = String(parts[0])
|
plugin = String(parts[0])
|
||||||
pluginOptions = String(parts[1])
|
pluginOptions = String(parts[1])
|
||||||
|
} else if parts.count == 1 {
|
||||||
|
plugin = String(parts[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,24 @@ class ServerProfileTests: XCTestCase {
|
|||||||
XCTAssertEqual(profile?.remark, "Overriden")
|
XCTAssertEqual(profile?.remark, "Overriden")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testInitWithSIP002URLProfileWithSIP003PluginNoPluginOpts() {
|
||||||
|
let url = URL(string: "ss://YWVzLTI1Ni1jZmI6cGFzc3dvcmQ=@134.209.56.100:8088/?plugin=v2ray-plugin;#moon-v2ray")!
|
||||||
|
|
||||||
|
let profile = ServerProfile(url: url)
|
||||||
|
|
||||||
|
XCTAssertNotNil(profile)
|
||||||
|
XCTAssertEqual(profile?.plugin, "v2ray-plugin")
|
||||||
|
}
|
||||||
|
|
||||||
|
func testInitWithSIP002URLProfileWithSIP003Plugin() {
|
||||||
|
let url = URL(string: "ss://YWVzLTI1Ni1jZmI6cGFzc3dvcmQ=@134.209.56.100:8088/?plugin=v2ray-plugin;tls#moon-v2ray")!
|
||||||
|
|
||||||
|
let profile = ServerProfile(url: url)
|
||||||
|
|
||||||
|
XCTAssertNotNil(profile)
|
||||||
|
XCTAssertEqual(profile?.plugin, "v2ray-plugin")
|
||||||
|
}
|
||||||
|
|
||||||
func testPerformanceExample() {
|
func testPerformanceExample() {
|
||||||
// This is an example of a performance test case.
|
// This is an example of a performance test case.
|
||||||
self.measure {
|
self.measure {
|
||||||
@ -149,4 +167,5 @@ class ServerProfileTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user