diff --git a/Shared/ThirdPartyProxyManager.swift b/Shared/ThirdPartyProxyManager.swift index 14f3844..afdcc4a 100644 --- a/Shared/ThirdPartyProxyManager.swift +++ b/Shared/ThirdPartyProxyManager.swift @@ -254,6 +254,8 @@ final class ThirdPartyProxyManager: ObservableObject { } enum ThirdPartyProxyClient: String, CaseIterable, Identifiable { + static let moduleSubscriptionVersion = "1.0.0" + case shadowrocket case surge case quantumultX @@ -309,7 +311,7 @@ enum ThirdPartyProxyClient: String, CaseIterable, Identifiable { case .shadowrocket: url = "\(prefix)\(directory)/wloc.module" } - return URL(string: url)! + return URL(string: "\(url)?v=\(Self.moduleSubscriptionVersion)")! } var launchURL: URL? { diff --git a/Tests/PaopaoLocationSpooferTests/ThirdPartyProxyManagerTests.swift b/Tests/PaopaoLocationSpooferTests/ThirdPartyProxyManagerTests.swift index 93a2d40..870da83 100644 --- a/Tests/PaopaoLocationSpooferTests/ThirdPartyProxyManagerTests.swift +++ b/Tests/PaopaoLocationSpooferTests/ThirdPartyProxyManagerTests.swift @@ -84,12 +84,18 @@ final class ThirdPartyProxyManagerTests: XCTestCase { XCTAssertTrue(ThirdPartyProxyClient.stash.subscriptionURL.absoluteString.hasPrefix( "https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/" )) - XCTAssertTrue(ThirdPartyProxyClient.stash.subscriptionURL.absoluteString.hasSuffix( - "/Resources/ThirdPartyProxyModules/wloc.stoverride" - )) - XCTAssertTrue(ThirdPartyProxyClient.shadowrocket.subscriptionURL.absoluteString.hasSuffix( - "/Resources/ThirdPartyProxyModules/wloc.module" - )) + let stashComponents = URLComponents( + url: ThirdPartyProxyClient.stash.subscriptionURL, + resolvingAgainstBaseURL: false + ) + let shadowrocketComponents = URLComponents( + url: ThirdPartyProxyClient.shadowrocket.subscriptionURL, + resolvingAgainstBaseURL: false + ) + XCTAssertEqual(stashComponents?.path, "/https://raw.githubusercontent.com/xweiba/location-spoofer/main/Resources/ThirdPartyProxyModules/wloc.stoverride") + XCTAssertEqual(shadowrocketComponents?.path, "/https://raw.githubusercontent.com/xweiba/location-spoofer/main/Resources/ThirdPartyProxyModules/wloc.module") + XCTAssertEqual(stashComponents?.queryItems?.first?.value, ThirdPartyProxyClient.moduleSubscriptionVersion) + XCTAssertEqual(shadowrocketComponents?.queryItems?.first?.value, ThirdPartyProxyClient.moduleSubscriptionVersion) XCTAssertEqual(ThirdPartyProxyClient.shadowrocket.launchURL?.scheme, "shadowrocket") XCTAssertEqual(ThirdPartyProxyClient.surge.launchURL?.scheme, "surge") XCTAssertEqual(ThirdPartyProxyClient.quantumultX.launchURL?.scheme, "quantumult-x") diff --git a/docs/THIRD_PARTY_MODULES.md b/docs/THIRD_PARTY_MODULES.md index 036e42a..df68ccf 100644 --- a/docs/THIRD_PARTY_MODULES.md +++ b/docs/THIRD_PARTY_MODULES.md @@ -12,6 +12,10 @@ module URL the App copies: - enabled by default: `gh-proxy.org` in front of GitHub Raw; - disabled: GitHub Raw directly. +The App appends the module version as a query parameter, such as `?v=1.0.0`. +Increment this value whenever an existing module path changes so proxy clients +do not reuse a previously cached subscription body. + | Module file | Client | |---|---| | `wloc.module` | Shadowrocket |