@whotracksme/reporting 12.1.5 β 12.1.7
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/.github/workflows/release.yml +2 -2
- package/.github/workflows/tests.yml +2 -2
- package/.tool-versions +1 -1
- package/CHANGELOG.md +38 -0
- package/communication/package.json +1 -1
- package/communication/src/padding.js +0 -2
- package/eslint.config.js +34 -0
- package/package.json +5 -3
- package/reporting/package.json +3 -3
- package/reporting/src/alive-message-generator.js +1 -1
- package/reporting/src/doublefetch-page-handler.js +2 -2
- package/reporting/src/duplicate-detector.js +1 -3
- package/reporting/src/hash-detector-v2/index.js +1 -1
- package/reporting/src/http.js +2 -3
- package/reporting/src/md5.js +0 -1
- package/reporting/src/nav-tracking-detector.js +2 -2
- package/reporting/src/network.js +1 -1
- package/reporting/src/page-aggregator.js +1 -1
- package/reporting/src/page-quorum-check-handler.js +1 -1
- package/reporting/src/page-structure.js +1 -1
- package/reporting/src/pagedb.js +1 -1
- package/reporting/src/pages.js +2 -2
- package/reporting/src/patterns-updater.js +1 -1
- package/reporting/src/patterns.js +11 -11
- package/reporting/src/popularity-estimator.js +1 -1
- package/reporting/src/random.js +0 -2
- package/reporting/src/request/index.js +1 -7
- package/reporting/src/request/utils/time.js +5 -22
- package/reporting/src/sanitizer.js +1 -1
- package/reporting/src/search-extractor.js +2 -5
- package/reporting/src/url-cleaner.js +9 -6
- package/reporting/src/utils/url.js +2 -2
- package/reporting/test/duplicate-detector.spec.js +0 -1
- package/reporting/test/pages.spec.js +1 -1
- package/reporting/test/patterns-updater.spec.js +1 -1
- package/reporting/test/patterns.spec.js +1 -1
- package/reporting/test/popularity-estimator.spec.js +6 -0
- package/reporting/test/request/index.test.js +0 -1
- package/reporting/test/search-extractor.spec.js +1 -1
- package/reporting/test/seq-executor.spec.js +2 -2
- package/reporting/test/url-cleaner.spec.js +21 -0
- package/reporting/test/utils/url.spec.js +0 -1
- package/reporting/test/utils.spec.js +1 -1
- package/.eslintignore +0 -4
- package/.eslintrc +0 -16
package/.tool-versions
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
nodejs 24.
|
|
1
|
+
nodejs 24.22.1
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
# v12.1.7 (Fri Oct 23 2026)
|
|
2
|
+
|
|
3
|
+
#### π Bug Fix
|
|
4
|
+
|
|
5
|
+
- remove unnecessary "requestBody" option [#248](https://github.com/whotracksme/webextension-packages/pull/248) ([@philipp-classen](https://github.com/philipp-classen))
|
|
6
|
+
|
|
7
|
+
#### π Internal
|
|
8
|
+
|
|
9
|
+
- CI: upgrade actions to fix warnings [#249](https://github.com/whotracksme/webextension-packages/pull/249) ([@philipp-classen](https://github.com/philipp-classen))
|
|
10
|
+
|
|
11
|
+
#### Authors: 1
|
|
12
|
+
|
|
13
|
+
- Philipp ClaΓen ([@philipp-classen](https://github.com/philipp-classen))
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# v12.1.6 (Mon Oct 12 2026)
|
|
18
|
+
|
|
19
|
+
#### π Bug Fix
|
|
20
|
+
|
|
21
|
+
- Fixed: removeQueryParams incorrectly replaced parts of the fragment [#247](https://github.com/whotracksme/webextension-packages/pull/247) ([@philipp-classen](https://github.com/philipp-classen))
|
|
22
|
+
|
|
23
|
+
#### π Internal
|
|
24
|
+
|
|
25
|
+
- Update remaining dependencies [#245](https://github.com/whotracksme/webextension-packages/pull/245) ([@philipp-classen](https://github.com/philipp-classen))
|
|
26
|
+
- Upgrade eslint from 8.x to 10.12.0 [#244](https://github.com/whotracksme/webextension-packages/pull/244) ([@philipp-classen](https://github.com/philipp-classen))
|
|
27
|
+
- Simplification: getTime [#243](https://github.com/whotracksme/webextension-packages/pull/243) ([@philipp-classen](https://github.com/philipp-classen))
|
|
28
|
+
|
|
29
|
+
#### π§ͺ Tests
|
|
30
|
+
|
|
31
|
+
- Fix flakey test [#246](https://github.com/whotracksme/webextension-packages/pull/246) ([@philipp-classen](https://github.com/philipp-classen))
|
|
32
|
+
|
|
33
|
+
#### Authors: 1
|
|
34
|
+
|
|
35
|
+
- Philipp ClaΓen ([@philipp-classen](https://github.com/philipp-classen))
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
1
39
|
# v12.1.5 (Mon Oct 12 2026)
|
|
2
40
|
|
|
3
41
|
#### π Bug Fix
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
4
|
+
|
|
5
|
+
const jsFilesOnly = (config) => ({ ...config, files: ['**/*.js'] });
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
{
|
|
9
|
+
// keep the lint scope at **/*.js (flat config would also collect .mjs/.cjs)
|
|
10
|
+
ignores: [
|
|
11
|
+
'**/*.bundle.js',
|
|
12
|
+
'**/trackers-preview-generated.js',
|
|
13
|
+
'**/scripts/**/*.js',
|
|
14
|
+
'reporting/example/offscreen/**',
|
|
15
|
+
'**/*.mjs',
|
|
16
|
+
'**/*.cjs',
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
jsFilesOnly({
|
|
20
|
+
languageOptions: {
|
|
21
|
+
ecmaVersion: 2022,
|
|
22
|
+
sourceType: 'module',
|
|
23
|
+
globals: {
|
|
24
|
+
...globals.es2022,
|
|
25
|
+
...globals.browser,
|
|
26
|
+
...globals.serviceworker,
|
|
27
|
+
...globals.webextensions,
|
|
28
|
+
...globals.mocha,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
jsFilesOnly(js.configs.recommended),
|
|
33
|
+
jsFilesOnly(eslintPluginPrettierRecommended),
|
|
34
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whotracksme/reporting",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./sanitizer": "./reporting/src/sanitizer.js",
|
|
@@ -38,10 +38,12 @@
|
|
|
38
38
|
"communication"
|
|
39
39
|
],
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
41
|
+
"@eslint/js": "^10.0.1",
|
|
42
|
+
"auto": "^11.3.6",
|
|
43
|
+
"eslint": "^10.12.0",
|
|
43
44
|
"eslint-config-prettier": "^10.1.8",
|
|
44
45
|
"eslint-plugin-prettier": "^5.5.6",
|
|
46
|
+
"globals": "^17.13.0",
|
|
45
47
|
"prettier": "3.9.9"
|
|
46
48
|
},
|
|
47
49
|
"dependencies": {
|
package/reporting/package.json
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"karma-rollup-preprocessor": "^7.0.8",
|
|
36
36
|
"karma-sinon": "^1.0.5",
|
|
37
37
|
"mocha": "^12.0.3",
|
|
38
|
-
"puppeteer-core": "^
|
|
38
|
+
"puppeteer-core": "^25.12.0",
|
|
39
39
|
"rollup": "^4.64.2",
|
|
40
40
|
"rollup-plugin-copy": "^3.5.0",
|
|
41
41
|
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"sinon": "^22.1.0",
|
|
44
44
|
"sinon-chai": "^4.0.1",
|
|
45
45
|
"sinon-chrome": "^3.0.1",
|
|
46
|
-
"web-ext": "^
|
|
47
|
-
"webdriverio": "^
|
|
46
|
+
"web-ext": "^10.7.0",
|
|
47
|
+
"webdriverio": "^10.0.0",
|
|
48
48
|
"ws": "^8.22.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
@@ -53,7 +53,7 @@ export function toTrustedUrl(url, { baseUrl, log, logWarn }) {
|
|
|
53
53
|
let from;
|
|
54
54
|
try {
|
|
55
55
|
from = new URL(baseUrl);
|
|
56
|
-
} catch
|
|
56
|
+
} catch {
|
|
57
57
|
logWarn('Invalid baseUrl (possible but unexpected):', baseUrl);
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
@@ -61,7 +61,7 @@ export function toTrustedUrl(url, { baseUrl, log, logWarn }) {
|
|
|
61
61
|
let to;
|
|
62
62
|
try {
|
|
63
63
|
to = new URL(url, baseUrl);
|
|
64
|
-
} catch
|
|
64
|
+
} catch {
|
|
65
65
|
log('Ignore invalid url:', url);
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
@@ -149,9 +149,7 @@ function extractPath(obj, path, pos = 0) {
|
|
|
149
149
|
*/
|
|
150
150
|
export function computeDeduplicationKey({ body, deduplicateBy = '' }) {
|
|
151
151
|
let keys = body.payload;
|
|
152
|
-
if (
|
|
153
|
-
keys = body.payload;
|
|
154
|
-
} else {
|
|
152
|
+
if (deduplicateBy) {
|
|
155
153
|
keys = deduplicateBy
|
|
156
154
|
.split(',')
|
|
157
155
|
.map((path) => extractPath(body.payload, path.split('.'), 0).value);
|
package/reporting/src/http.js
CHANGED
|
@@ -200,7 +200,6 @@ function headerOverrideViaWebRequestAPI({ url, headers, requestType }) {
|
|
|
200
200
|
const headerNames = Object.keys(headers);
|
|
201
201
|
const normalizedHeaders = headerNames.map((x) => x.toLowerCase());
|
|
202
202
|
|
|
203
|
-
/* eslint-disable no-param-reassign */
|
|
204
203
|
details.requestHeaders = details.requestHeaders.filter(
|
|
205
204
|
(header) => !normalizedHeaders.includes(header.name.toLowerCase()),
|
|
206
205
|
);
|
|
@@ -837,7 +836,7 @@ async function anonymousHttpGet_(originalUrl, params = {}) {
|
|
|
837
836
|
'extraHeaders', // Note: needed for Chromium, but will be rejected by Firefox
|
|
838
837
|
],
|
|
839
838
|
);
|
|
840
|
-
} catch
|
|
839
|
+
} catch {
|
|
841
840
|
chrome.webRequest.onBeforeSendHeaders.addListener(
|
|
842
841
|
onBeforeSendHeaders,
|
|
843
842
|
{ urls: matchedUrls },
|
|
@@ -878,7 +877,7 @@ async function anonymousHttpGet_(originalUrl, params = {}) {
|
|
|
878
877
|
'extraHeaders', // Note: needed for Chromium, but will be rejected by Firefox
|
|
879
878
|
],
|
|
880
879
|
);
|
|
881
|
-
} catch
|
|
880
|
+
} catch {
|
|
882
881
|
chrome.webRequest.onHeadersReceived.addListener(
|
|
883
882
|
onHeadersReceived,
|
|
884
883
|
{ urls: matchedUrls },
|
package/reporting/src/md5.js
CHANGED
|
@@ -15,7 +15,6 @@ import MapCache from './fixed-size-cache.js';
|
|
|
15
15
|
* Largely based on js-md5 (https://github.com/emn178/js-md5)
|
|
16
16
|
* by Chen, Yi-Cyuan [emn178@gmail.com]
|
|
17
17
|
*/
|
|
18
|
-
/* eslint-disable no-mixed-operators, no-bitwise, no-plusplus */
|
|
19
18
|
|
|
20
19
|
const state = new Int32Array(4);
|
|
21
20
|
const buffer = new ArrayBuffer(68);
|
|
@@ -19,7 +19,7 @@ const SECOND = 1000;
|
|
|
19
19
|
function tryParseHostname(url) {
|
|
20
20
|
try {
|
|
21
21
|
return new URL(url).host;
|
|
22
|
-
} catch
|
|
22
|
+
} catch {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -28,7 +28,7 @@ function hasQueryParams(url, params) {
|
|
|
28
28
|
try {
|
|
29
29
|
const { searchParams } = new URL(url);
|
|
30
30
|
return params.every((key) => searchParams.has(key));
|
|
31
|
-
} catch
|
|
31
|
+
} catch {
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
}
|
package/reporting/src/network.js
CHANGED
|
@@ -149,7 +149,7 @@ export default class PageAggregator {
|
|
|
149
149
|
logger.debug('Creating', jobs.length, 'jobs for expired pages:', jobs);
|
|
150
150
|
await this.jobScheduler.registerJobs(jobs);
|
|
151
151
|
numJobsCreated += expiredPages.length;
|
|
152
|
-
} catch
|
|
152
|
+
} catch {
|
|
153
153
|
logger.error('Failed to register jobs:', jobs.length, 'jobs were lost');
|
|
154
154
|
logger.debug('Lost jobs:', jobs);
|
|
155
155
|
return { numJobsCreated };
|
|
@@ -166,7 +166,7 @@ export async function analyzePageStructure(doc) {
|
|
|
166
166
|
// 2) some websites use arrays, some split it across multiple scripts
|
|
167
167
|
// ==> everything becomes an array
|
|
168
168
|
parsedJson = Array.isArray(parsedJson) ? parsedJson : [parsedJson];
|
|
169
|
-
} catch
|
|
169
|
+
} catch {
|
|
170
170
|
continue; // ignore broken JSON
|
|
171
171
|
}
|
|
172
172
|
for (const json of parsedJson) {
|
package/reporting/src/pagedb.js
CHANGED
|
@@ -28,7 +28,7 @@ function normalizeUrl(url) {
|
|
|
28
28
|
const tmp = new URL(url);
|
|
29
29
|
tmp.hash = '';
|
|
30
30
|
return tmp.toString();
|
|
31
|
-
} catch
|
|
31
|
+
} catch {
|
|
32
32
|
// It is not necessarily a bug this code path hits, but ideally
|
|
33
33
|
// invalid URLs should have been filtered already.
|
|
34
34
|
logger.warn('Bad URL detected:', url, '(ignore this page and continue)');
|
package/reporting/src/pages.js
CHANGED
|
@@ -102,7 +102,7 @@ function isRealPage(url) {
|
|
|
102
102
|
function sameHostname(url1, url2) {
|
|
103
103
|
try {
|
|
104
104
|
return new URL(url1).hostname === new URL(url2).hostname;
|
|
105
|
-
} catch
|
|
105
|
+
} catch {
|
|
106
106
|
return false;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -880,7 +880,7 @@ export default class Pages {
|
|
|
880
880
|
{ urls: ['<all_urls>'] },
|
|
881
881
|
['responseHeaders'],
|
|
882
882
|
);
|
|
883
|
-
} catch
|
|
883
|
+
} catch {
|
|
884
884
|
this.chrome.webRequest[type].addListener(handler, {
|
|
885
885
|
urls: ['<all_urls>'],
|
|
886
886
|
});
|
|
@@ -118,7 +118,7 @@ const TRANSFORMS = new Map(
|
|
|
118
118
|
// we only need the query parameter, but to handle relative
|
|
119
119
|
// URLs we have to pass a base URL (any domain will work)
|
|
120
120
|
return new URL(url, 'http://x').searchParams.get(queryParam);
|
|
121
|
-
} catch
|
|
121
|
+
} catch {
|
|
122
122
|
return null;
|
|
123
123
|
}
|
|
124
124
|
},
|
|
@@ -185,7 +185,7 @@ const TRANSFORMS = new Map(
|
|
|
185
185
|
requireString(url);
|
|
186
186
|
try {
|
|
187
187
|
return sanitizeUrl(url).safeUrl;
|
|
188
|
-
} catch
|
|
188
|
+
} catch {
|
|
189
189
|
return null;
|
|
190
190
|
}
|
|
191
191
|
},
|
|
@@ -204,7 +204,7 @@ const TRANSFORMS = new Map(
|
|
|
204
204
|
requireString(url);
|
|
205
205
|
try {
|
|
206
206
|
return sanitizeUrl(url, { strict: true }).safeUrl;
|
|
207
|
-
} catch
|
|
207
|
+
} catch {
|
|
208
208
|
return null;
|
|
209
209
|
}
|
|
210
210
|
},
|
|
@@ -219,7 +219,7 @@ const TRANSFORMS = new Map(
|
|
|
219
219
|
try {
|
|
220
220
|
return sanitizeUrl(url, { strict: false, tryPreservePath: true })
|
|
221
221
|
.safeUrl;
|
|
222
|
-
} catch
|
|
222
|
+
} catch {
|
|
223
223
|
return null;
|
|
224
224
|
}
|
|
225
225
|
},
|
|
@@ -257,7 +257,7 @@ const TRANSFORMS = new Map(
|
|
|
257
257
|
requireString(text);
|
|
258
258
|
try {
|
|
259
259
|
return decodeURIComponent(text);
|
|
260
|
-
} catch
|
|
260
|
+
} catch {
|
|
261
261
|
return null;
|
|
262
262
|
}
|
|
263
263
|
},
|
|
@@ -269,7 +269,7 @@ const TRANSFORMS = new Map(
|
|
|
269
269
|
requireString(text);
|
|
270
270
|
try {
|
|
271
271
|
return decodeURIComponent(text);
|
|
272
|
-
} catch
|
|
272
|
+
} catch {
|
|
273
273
|
return text;
|
|
274
274
|
}
|
|
275
275
|
},
|
|
@@ -308,7 +308,7 @@ const TRANSFORMS = new Map(
|
|
|
308
308
|
}
|
|
309
309
|
// prevent uncontrolled text extraction
|
|
310
310
|
return '';
|
|
311
|
-
} catch
|
|
311
|
+
} catch {
|
|
312
312
|
return '';
|
|
313
313
|
}
|
|
314
314
|
},
|
|
@@ -338,7 +338,7 @@ const TRANSFORMS = new Map(
|
|
|
338
338
|
}
|
|
339
339
|
try {
|
|
340
340
|
return text.replace(new RegExp(pattern), '');
|
|
341
|
-
} catch
|
|
341
|
+
} catch {
|
|
342
342
|
return '';
|
|
343
343
|
}
|
|
344
344
|
},
|
|
@@ -360,7 +360,7 @@ const TRANSFORMS = new Map(
|
|
|
360
360
|
}
|
|
361
361
|
try {
|
|
362
362
|
return text.replaceAll(new RegExp(pattern, 'g'), '');
|
|
363
|
-
} catch
|
|
363
|
+
} catch {
|
|
364
364
|
return '';
|
|
365
365
|
}
|
|
366
366
|
},
|
|
@@ -384,7 +384,7 @@ const TRANSFORMS = new Map(
|
|
|
384
384
|
try {
|
|
385
385
|
const m = new RegExp(pattern).exec(text);
|
|
386
386
|
return m ? m[0] : '';
|
|
387
|
-
} catch
|
|
387
|
+
} catch {
|
|
388
388
|
return '';
|
|
389
389
|
}
|
|
390
390
|
},
|
|
@@ -435,7 +435,7 @@ const TRANSFORMS = new Map(
|
|
|
435
435
|
// "match" is slightly faster for non-empty-matching patterns
|
|
436
436
|
const matches = text.match(regexp);
|
|
437
437
|
return matches ? matches.join('') : '';
|
|
438
|
-
} catch
|
|
438
|
+
} catch {
|
|
439
439
|
return '';
|
|
440
440
|
}
|
|
441
441
|
},
|
|
@@ -558,7 +558,7 @@ export default class PopularityEstimator {
|
|
|
558
558
|
const allJobs = jobBatchesPerRotation.flat();
|
|
559
559
|
try {
|
|
560
560
|
await this.jobScheduler.registerJobs(allJobs);
|
|
561
|
-
} catch
|
|
561
|
+
} catch {
|
|
562
562
|
logger.error('Failed to register jobs. These were lost:', allJobs);
|
|
563
563
|
}
|
|
564
564
|
}
|
package/reporting/src/random.js
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
import Bowser from 'bowser';
|
|
13
13
|
|
|
14
|
-
/* eslint-disable no-param-reassign */
|
|
15
14
|
import { isLocalIP } from '../network.js';
|
|
16
15
|
import Config from './config.js';
|
|
17
16
|
import Database from './database.js';
|
|
@@ -107,12 +106,7 @@ export default class RequestReporter {
|
|
|
107
106
|
|
|
108
107
|
this.ready = false;
|
|
109
108
|
|
|
110
|
-
const safeOptions = [
|
|
111
|
-
'extraHeaders',
|
|
112
|
-
'requestBody',
|
|
113
|
-
'requestHeaders',
|
|
114
|
-
'responseHeaders',
|
|
115
|
-
];
|
|
109
|
+
const safeOptions = ['extraHeaders', 'requestHeaders', 'responseHeaders'];
|
|
116
110
|
if (hasBlockingWebRequest()) {
|
|
117
111
|
safeOptions.push('blocking');
|
|
118
112
|
}
|
|
@@ -9,32 +9,15 @@
|
|
|
9
9
|
* file, You can obtain one at http://mozilla.org/MPL/2.0
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
/* eslint prefer-template: 'off' */
|
|
13
|
-
|
|
14
|
-
// this is the sanitised timestamp retrieved from humanweb.
|
|
15
|
-
let hwTs = null;
|
|
16
|
-
|
|
17
12
|
/** Get datetime string of the current hour in the format YYYYMMDDHH
|
|
18
13
|
*/
|
|
19
14
|
export function getTime() {
|
|
20
15
|
const date = new Date();
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
let m = null;
|
|
27
|
-
let y = null;
|
|
28
|
-
d = (date.getDate() < 10 ? '0' : '') + date.getDate();
|
|
29
|
-
m = (date.getMonth() < 9 ? '0' : '') + parseInt(date.getMonth() + 1, 10);
|
|
30
|
-
h = (date.getUTCHours() < 10 ? '0' : '') + date.getUTCHours();
|
|
31
|
-
y = date.getFullYear();
|
|
32
|
-
_ts = y + '' + m + '' + d + '' + h;
|
|
33
|
-
} else {
|
|
34
|
-
h = (date.getUTCHours() < 10 ? '0' : '') + date.getUTCHours();
|
|
35
|
-
_ts = ts + '' + h;
|
|
36
|
-
}
|
|
37
|
-
return _ts;
|
|
16
|
+
const d = (date.getDate() < 10 ? '0' : '') + date.getDate();
|
|
17
|
+
const m = (date.getMonth() < 9 ? '0' : '') + (date.getMonth() + 1);
|
|
18
|
+
const y = date.getFullYear();
|
|
19
|
+
const h = (date.getUTCHours() < 10 ? '0' : '') + date.getUTCHours();
|
|
20
|
+
return `${y}${m}${d}${h}`;
|
|
38
21
|
}
|
|
39
22
|
|
|
40
23
|
export function newUTCDate() {
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
* file, You can obtain one at http://mozilla.org/MPL/2.0
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
/* eslint-disable no-continue */
|
|
13
|
-
|
|
14
12
|
import logger from './logger';
|
|
15
13
|
import parseHtml from './html-parser';
|
|
16
14
|
import { fastHash } from './utils';
|
|
@@ -259,7 +257,6 @@ export default class SearchExtractor {
|
|
|
259
257
|
// "requiredKeys" property. If not specified, all keys of the array entry need
|
|
260
258
|
// to be present; otherwise, the entry will be skipped.
|
|
261
259
|
const messages = [];
|
|
262
|
-
// eslint-disable-line no-labels, no-restricted-syntax
|
|
263
260
|
nextaction: for (const [action, schema] of Object.entries(output)) {
|
|
264
261
|
const payload = {};
|
|
265
262
|
for (const {
|
|
@@ -277,7 +274,7 @@ export default class SearchExtractor {
|
|
|
277
274
|
if (input[source].first) {
|
|
278
275
|
// case 1: single extracted value
|
|
279
276
|
if (!optional && !isPresent(found[source][key])) {
|
|
280
|
-
continue nextaction;
|
|
277
|
+
continue nextaction;
|
|
281
278
|
}
|
|
282
279
|
payload[key] = found[source][key] ?? null;
|
|
283
280
|
} else if (input[source].all) {
|
|
@@ -298,7 +295,7 @@ export default class SearchExtractor {
|
|
|
298
295
|
required.every((x) => isPresent(entry[x]));
|
|
299
296
|
const cleanedResults = results.filter(allFieldsPresent);
|
|
300
297
|
if (cleanedResults.length === 0 && !optional) {
|
|
301
|
-
continue nextaction;
|
|
298
|
+
continue nextaction;
|
|
302
299
|
}
|
|
303
300
|
payload[key] = { ...cleanedResults };
|
|
304
301
|
} else {
|
|
@@ -25,11 +25,14 @@ export function removeQueryParams(url, queryParams) {
|
|
|
25
25
|
if (searchStart === -1) {
|
|
26
26
|
return url;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
|
|
29
|
+
const hashStart = url.indexOf('#');
|
|
30
|
+
const searchEnd = hashStart === -1 ? url.length : hashStart;
|
|
31
|
+
if (searchStart > searchEnd) {
|
|
32
|
+
return url;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const search = url.slice(searchStart + 1, searchEnd);
|
|
33
36
|
if (!search) {
|
|
34
37
|
return url;
|
|
35
38
|
}
|
|
@@ -38,7 +41,7 @@ export function removeQueryParams(url, queryParams) {
|
|
|
38
41
|
.filter((x) => !queryParams.includes(split0(x, '=')));
|
|
39
42
|
const beforeSearch = url.slice(0, searchStart);
|
|
40
43
|
|
|
41
|
-
const hash =
|
|
44
|
+
const hash = url.slice(searchEnd);
|
|
42
45
|
if (parts.length === 0) {
|
|
43
46
|
return beforeSearch + hash;
|
|
44
47
|
} else {
|
|
@@ -28,7 +28,7 @@ export function parse(url) {
|
|
|
28
28
|
try {
|
|
29
29
|
const parsed = new ImmutableURL(url);
|
|
30
30
|
return parsed;
|
|
31
|
-
} catch
|
|
31
|
+
} catch {
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -51,7 +51,7 @@ function tryDecode(fn) {
|
|
|
51
51
|
|
|
52
52
|
try {
|
|
53
53
|
return fn(url);
|
|
54
|
-
} catch
|
|
54
|
+
} catch {
|
|
55
55
|
return url;
|
|
56
56
|
}
|
|
57
57
|
};
|
|
@@ -22,7 +22,6 @@ function getUniqueId() {
|
|
|
22
22
|
return getUniqueId.uniqueId;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/* eslint-disable no-param-reassign */
|
|
26
25
|
function mkMessage({ action = 'test-action', payload, deduplicateBy } = {}) {
|
|
27
26
|
payload = payload || {
|
|
28
27
|
testFieldWithSeq: `test-field-${getUniqueId()}`,
|
|
@@ -1074,7 +1074,7 @@ describe('Test builtin primitives', function () {
|
|
|
1074
1074
|
let expected = '';
|
|
1075
1075
|
try {
|
|
1076
1076
|
expected = (text.match(new RegExp(pattern, 'g')) || []).join('');
|
|
1077
|
-
} catch
|
|
1077
|
+
} catch {
|
|
1078
1078
|
// invalid regular expression: expect the value to be cleared
|
|
1079
1079
|
}
|
|
1080
1080
|
expect(uut(text, pattern)).to.eql(expected);
|
|
@@ -91,6 +91,12 @@ describe('#PopularityEstimator', function () {
|
|
|
91
91
|
const _jobsRegistered = jobsRegistered;
|
|
92
92
|
|
|
93
93
|
jobScheduler = createInMemoryJobScheduler();
|
|
94
|
+
|
|
95
|
+
// Guarantees that we see "jobRegistered" events.
|
|
96
|
+
// (We are not clearing the queues by processing the jobs; so once the
|
|
97
|
+
// global job limit is reached, new jobs would be rejected.)
|
|
98
|
+
jobScheduler.globalJobLimit = Infinity;
|
|
99
|
+
|
|
94
100
|
jobScheduler.addObserver('jobRegistered', (job) => {
|
|
95
101
|
// Nasty pitfall: it would be nice to run assertions here, but they
|
|
96
102
|
// will not be visible in the console when the user runs them.
|
|
@@ -388,7 +388,6 @@ describe('RequestReporter', function () {
|
|
|
388
388
|
|
|
389
389
|
async function processRunloopUntil(timeout) {
|
|
390
390
|
const start = Date.now();
|
|
391
|
-
// eslint-disable-next-line no-constant-condition
|
|
392
391
|
while (true) {
|
|
393
392
|
const now = await clock.runToLast();
|
|
394
393
|
if (now - start > timeout) {
|
|
@@ -52,7 +52,7 @@ describe('#SeqExecutor', function () {
|
|
|
52
52
|
await uut.run(() => {
|
|
53
53
|
throw new Error(2);
|
|
54
54
|
});
|
|
55
|
-
} catch
|
|
55
|
+
} catch {
|
|
56
56
|
gotError2 = true;
|
|
57
57
|
}
|
|
58
58
|
if (!gotError2) {
|
|
@@ -66,7 +66,7 @@ describe('#SeqExecutor', function () {
|
|
|
66
66
|
await uut.run(async () => {
|
|
67
67
|
throw new Error(4);
|
|
68
68
|
});
|
|
69
|
-
} catch
|
|
69
|
+
} catch {
|
|
70
70
|
gotError4 = true;
|
|
71
71
|
}
|
|
72
72
|
if (!gotError4) {
|
|
@@ -26,6 +26,27 @@ describe('#removeQueryParams', function () {
|
|
|
26
26
|
removeQueryParams('https://example.test/path?foo=1&bar=2#baz', ['foo']),
|
|
27
27
|
).to.eql('https://example.test/path?bar=2#baz');
|
|
28
28
|
});
|
|
29
|
+
|
|
30
|
+
it('should not treat a "?" in the fragment as a query', function () {
|
|
31
|
+
expect(removeQueryParams('https://example.test/#?foo=1', ['foo'])).to.eql(
|
|
32
|
+
'https://example.test/#?foo=1',
|
|
33
|
+
);
|
|
34
|
+
expect(
|
|
35
|
+
removeQueryParams('https://example.test/#/path?foo=1&bar=2', ['foo']),
|
|
36
|
+
).to.eql('https://example.test/#/path?foo=1&bar=2');
|
|
37
|
+
expect(removeQueryParams('https://example.test/#?&', [''])).to.eql(
|
|
38
|
+
'https://example.test/#?&',
|
|
39
|
+
);
|
|
40
|
+
expect(
|
|
41
|
+
removeQueryParams('https://example.test/?foo=1#?foo=1', ['foo']),
|
|
42
|
+
).to.eql('https://example.test/#?foo=1');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should support complex examples with "?" and "#" appearing again in the fragment', function () {
|
|
46
|
+
expect(
|
|
47
|
+
removeQueryParams('https://example.test/a?b#c?d#e', ['b', 'c', 'd']),
|
|
48
|
+
).to.eql('https://example.test/a#c?d#e');
|
|
49
|
+
});
|
|
29
50
|
});
|
|
30
51
|
|
|
31
52
|
describe('should handle non-valid URLs gracefully', function () {
|
package/.eslintignore
DELETED
package/.eslintrc
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"es2022": true,
|
|
4
|
-
"browser": true,
|
|
5
|
-
"serviceworker": true,
|
|
6
|
-
"webextensions": true,
|
|
7
|
-
"mocha": true
|
|
8
|
-
},
|
|
9
|
-
"extends": [
|
|
10
|
-
"eslint:recommended",
|
|
11
|
-
"plugin:prettier/recommended"
|
|
12
|
-
],
|
|
13
|
-
"parserOptions": {
|
|
14
|
-
"sourceType": "module"
|
|
15
|
-
}
|
|
16
|
-
}
|