swpp-backends 2.0.3 → 2.0.4

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.
@@ -384,7 +384,7 @@ async function eachAllLinkInCss(domain, url, content, result, event) {
384
384
  i = right + 2;
385
385
  }
386
386
  sub.match(/(url\(.*?\))|(@import\s+['"].*?['"])|((https?:)?\/\/[^\s/$.?#].\S*)/g)
387
- ?.map(it => it.replace(/(^url\((['"]?))|((['"]?)\)$)|(^@import\s+['"])|(['"]$)/g, ''))
387
+ ?.map(it => it.replace(/(^url\(\s*(['"]?))|((['"]?\s*)\)$)|(^@import\s+['"])|(['"]$)/g, ''))
388
388
  ?.map(it => {
389
389
  switch (true) {
390
390
  case it.startsWith('http'):
@@ -31,6 +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.readNewVersionJson)().external.flag = userUpdate.flag;
34
35
  if (userUpdate.flag === (0, Variant_1.readOldVersionJson)()?.external?.flag)
35
36
  userUpdate = undefined;
36
37
  }
@@ -272,6 +273,11 @@ function zipJson(json) {
272
273
  * + **执行该函数前必须调用过 [calcEjectValues]**
273
274
  */
274
275
  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
+ }
275
281
  const map = (0, Variant_1.readMergeVersionMap)();
276
282
  let collide = new Set();
277
283
  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.3',
13
+ version: '2.0.4',
14
14
  cache: {
15
15
  readEjectData: Utils_1.readEjectData, readUpdateJson: Variant_1.readUpdateJson,
16
16
  readRules: Variant_1.readRules, readMergeVersionMap: Variant_1.readMergeVersionMap,
@@ -148,8 +148,8 @@
148
148
  // [debug escape]
149
149
  //如果需要清理全站
150
150
  if (refresh) {
151
- if (global !== oldVersion.global) list.refresh = true
152
- else list.clean(new CacheChangeExpression({'flag': 'all'}))
151
+ if (global !== oldVersion.global) list.force = true
152
+ else list.refresh = true
153
153
  }
154
154
  return {list, version: newVersion}
155
155
  })
@@ -185,22 +185,14 @@
185
185
  list.push(element)
186
186
  }
187
187
 
188
- /**
189
- * 清除列表,并将指定元素推入列表中
190
- * @param element {CacheChangeExpression} 要推入的元素,留空表示不推入
191
- */
192
- this.clean = element => {
193
- list.length = 0
194
- if (!element) this.push(element)
195
- }
196
-
197
188
  /**
198
189
  * 判断指定 URL 是否和某一条规则匹配
199
190
  * @param url {string} URL
200
191
  * @return {boolean}
201
192
  */
202
193
  this.match = url => {
203
- if (this.refresh) return true
194
+ if (this.force) return true
195
+ else if (this.refresh) return findCache(url).clean
204
196
  else {
205
197
  for (let it of list) {
206
198
  if (it.match(url)) return true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swpp-backends",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "main": "dist/index.js",
5
5
  "typings": "types/index.d.ts",
6
6
  "description": "Generate a powerful ServiceWorker for your website.",