swpp-backends 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,7 +17,7 @@ const Variant_1 = require("./Variant");
|
|
|
17
17
|
function buildServiceWorker() {
|
|
18
18
|
const rules = (0, Variant_1.readRules)();
|
|
19
19
|
const eject = (0, Utils_1.readEjectData)();
|
|
20
|
-
const { modifyRequest, fetchFile, getRaceUrls, getSpareUrls, blockRequest, config } = rules;
|
|
20
|
+
const { modifyRequest, skipRequest, fetchFile, getRaceUrls, getSpareUrls, blockRequest, config } = rules;
|
|
21
21
|
if (!config.serviceWorker) {
|
|
22
22
|
(0, Utils_1.error)('ServiceWorkerBuilder', '插件未开启该项');
|
|
23
23
|
throw '功能未开启';
|
|
@@ -62,6 +62,9 @@ function buildServiceWorker() {
|
|
|
62
62
|
else if (modify) handleFetch(fetchWithCors(request, false).catch(err => new Response(err, {status: 499})))
|
|
63
63
|
`);
|
|
64
64
|
}
|
|
65
|
+
if (skipRequest) {
|
|
66
|
+
content = content.replaceAll('// [skipRequest call]', `if (skipRequest(request)) return;`);
|
|
67
|
+
}
|
|
65
68
|
if (blockRequest) {
|
|
66
69
|
content = content.replace('// [blockRequest call]', `
|
|
67
70
|
if (blockRequest(url))
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const VersionAnalyzer_1 = require("./VersionAnalyzer");
|
|
|
10
10
|
const DomBuilder_1 = require("./DomBuilder");
|
|
11
11
|
// noinspection JSUnusedGlobalSymbols
|
|
12
12
|
exports.default = {
|
|
13
|
-
version: '2.2.
|
|
13
|
+
version: '2.2.1',
|
|
14
14
|
cache: {
|
|
15
15
|
readEjectData: Utils_1.readEjectData, readUpdateJson: Variant_1.readUpdateJson,
|
|
16
16
|
readRules: Variant_1.readRules, readMergeVersionMap: Variant_1.readMergeVersionMap,
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
// [blockRequest call]
|
|
84
84
|
if (request.method !== 'GET' || !request.url.startsWith('http')) return
|
|
85
85
|
// [modifyRequest call]
|
|
86
|
-
|
|
86
|
+
// [skipRequest call]
|
|
87
87
|
let cacheKey = url.hostname + url.pathname + url.search
|
|
88
88
|
let cache = cacheMap.get(cacheKey)
|
|
89
89
|
if (cache) {
|