swpp-backends 2.0.4 → 2.0.6
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.
package/dist/FileAnalyzer.js
CHANGED
|
@@ -108,10 +108,13 @@ async function buildVersionJson(protocol, domain, root) {
|
|
|
108
108
|
cacheInfoMap.forEach((value, key) => {
|
|
109
109
|
external[key] = value;
|
|
110
110
|
});
|
|
111
|
-
|
|
111
|
+
if ('update' in rules) {
|
|
112
|
+
external.swppFlag = rules.update.flag;
|
|
113
|
+
}
|
|
114
|
+
return (0, Variant_1.writeVariant)('newVersionJson', (0, Utils_1.deepFreeze)({
|
|
112
115
|
version: 3,
|
|
113
116
|
list, external
|
|
114
|
-
});
|
|
117
|
+
}));
|
|
115
118
|
}
|
|
116
119
|
exports.buildVersionJson = buildVersionJson;
|
|
117
120
|
/**
|
|
@@ -31,8 +31,7 @@ function buildUpdateJson(root, dif) {
|
|
|
31
31
|
(0, Utils_1.error)('UpdateJsonBuilder', '规则文件的 update 项目必须包含 flag 值!');
|
|
32
32
|
throw '规则文件的 update 不合规';
|
|
33
33
|
}
|
|
34
|
-
(0, Variant_1.
|
|
35
|
-
if (userUpdate.flag === (0, Variant_1.readOldVersionJson)()?.external?.flag)
|
|
34
|
+
if (userUpdate.flag === (0, Variant_1.readOldVersionJson)()?.external?.swppFlag)
|
|
36
35
|
userUpdate = undefined;
|
|
37
36
|
}
|
|
38
37
|
// 如果需要强制刷新直接返回
|
|
@@ -273,11 +272,6 @@ function zipJson(json) {
|
|
|
273
272
|
* + **执行该函数前必须调用过 [calcEjectValues]**
|
|
274
273
|
*/
|
|
275
274
|
function getShorthand(url, offset = 0) {
|
|
276
|
-
if (url.endsWith('/')) {
|
|
277
|
-
const startIndex = url.indexOf('//') + 2;
|
|
278
|
-
if (url.indexOf('/', startIndex) === url.length - 1)
|
|
279
|
-
return '/';
|
|
280
|
-
}
|
|
281
275
|
const map = (0, Variant_1.readMergeVersionMap)();
|
|
282
276
|
let collide = new Set();
|
|
283
277
|
for (let mapKey in map) {
|
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.0.
|
|
13
|
+
version: '2.0.6',
|
|
14
14
|
cache: {
|
|
15
15
|
readEjectData: Utils_1.readEjectData, readUpdateJson: Variant_1.readUpdateJson,
|
|
16
16
|
readRules: Variant_1.readRules, readMergeVersionMap: Variant_1.readMergeVersionMap,
|
|
@@ -194,8 +194,9 @@
|
|
|
194
194
|
if (this.force) return true
|
|
195
195
|
else if (this.refresh) return findCache(url).clean
|
|
196
196
|
else {
|
|
197
|
+
const obj = new URL(url)
|
|
197
198
|
for (let it of list) {
|
|
198
|
-
if (it.match(
|
|
199
|
+
if (it.match(obj)) return true
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
202
|
return false
|
|
@@ -230,13 +231,14 @@
|
|
|
230
231
|
case 'html':
|
|
231
232
|
return url => url.match(/(\/|\.html)$/)
|
|
232
233
|
case 'end':
|
|
233
|
-
return url => forEachValues(value => url.endsWith(value))
|
|
234
|
+
return url => forEachValues(value => url.href.endsWith(value))
|
|
234
235
|
case 'begin':
|
|
235
|
-
return url => forEachValues(value => url.startsWith(value))
|
|
236
|
+
return url => forEachValues(value => url.pathname.startsWith(value))
|
|
236
237
|
case 'str':
|
|
237
|
-
return url => forEachValues(value => url.includes(value))
|
|
238
|
+
return url => forEachValues(value => url.href.includes(value))
|
|
238
239
|
case 'reg':
|
|
239
|
-
|
|
240
|
+
// noinspection JSCheckFunctionSignatures
|
|
241
|
+
return url => forEachValues(value => url.href.match(new RegExp(value, 'i')))
|
|
240
242
|
default: throw `未知表达式:${JSON.stringify(json)}`
|
|
241
243
|
}
|
|
242
244
|
}
|