fix: bust third-party module cache

This commit is contained in:
xweiba
2026-08-10 13:39:58 +08:00
parent 41dfe7a8ed
commit 9510d9aa42
3 changed files with 19 additions and 7 deletions
+3 -1
View File
@@ -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? {
@@ -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")
+4
View File
@@ -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 |