@whotracksme/reporting 12.1.17 β†’ 12.1.18

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v12.1.18 (Thu Nov 19 2026)
2
+
3
+ #### πŸ› Bug Fix
4
+
5
+ - fixed: doublefetch ignored the download limit [#260](https://github.com/whotracksme/webextension-packages/pull/260) ([@philipp-classen](https://github.com/philipp-classen))
6
+
7
+ #### Authors: 1
8
+
9
+ - Philipp Claßen ([@philipp-classen](https://github.com/philipp-classen))
10
+
11
+ ---
12
+
1
13
  # v12.1.17 (Thu Nov 19 2026)
2
14
 
3
15
  #### πŸ› Bug Fix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whotracksme/reporting",
3
- "version": "12.1.17",
3
+ "version": "12.1.18",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./sanitizer": "./reporting/src/sanitizer.js",
@@ -312,7 +312,8 @@ function unbreakConfig(url) {
312
312
  }
313
313
 
314
314
  class CachedPageFetcher {
315
- constructor() {
315
+ constructor({ downloadLimit } = {}) {
316
+ this.downloadLimit = downloadLimit;
316
317
  this.urlToAsyncPageStructure = new Map();
317
318
  }
318
319
 
@@ -380,7 +381,7 @@ export default class DoublefetchPageHandler {
380
381
  newPageApprover,
381
382
 
382
383
  // by default, use a separate fetcher cache per job
383
- pageFetcherProvider = () => new CachedPageFetcher(),
384
+ pageFetcherProvider = (options) => new CachedPageFetcher(options),
384
385
  }) {
385
386
  this.sanitizer = requireParam(sanitizer);
386
387
  this.newPageApprover = requireParam(newPageApprover);
@@ -420,7 +421,9 @@ export default class DoublefetchPageHandler {
420
421
  throw new BadJobError('preDoublefetch missing');
421
422
  }
422
423
 
423
- const pageFetcher = this.pageFetcherProvider();
424
+ const pageFetcher = this.pageFetcherProvider({
425
+ downloadLimit: this.downloadLimit,
426
+ });
424
427
  const log = logger.debug.bind(logger.debug, `[doublefetch=${url}]`);
425
428
  const logWarn = logger.warn.bind(logger.warn, `[doublefetch=${url}]`);
426
429
  const withBaseUrl = (baseUrl) => ({ baseUrl, log, logWarn });
@@ -10,6 +10,7 @@
10
10
  */
11
11
 
12
12
  import { expect, assert } from 'chai';
13
+ import sinon from 'sinon';
13
14
  import * as fc from 'fast-check';
14
15
 
15
16
  import Sanitizer from '../src/sanitizer';
@@ -990,6 +991,75 @@ describe('DoublefetchPageHandler', function () {
990
991
  expect(details).to.be.a('string').that.is.not.empty;
991
992
  });
992
993
  });
994
+
995
+ describe('with the default page fetcher', function () {
996
+ const url = 'https://example.com/some/article';
997
+ let fetchStub;
998
+ let numDownloads;
999
+
1000
+ function mockServerResponse({ contentLength }) {
1001
+ fetchStub.callsFake(async (requestedUrl) => ({
1002
+ ok: true,
1003
+ status: 200,
1004
+ type: 'basic',
1005
+ url: requestedUrl,
1006
+ headers: new Headers({
1007
+ 'content-type': 'text/html',
1008
+ 'content-length': String(contentLength),
1009
+ }),
1010
+ async text() {
1011
+ numDownloads += 1;
1012
+ return '<!doctype html><html><head><title>Some article</title></head></html>';
1013
+ },
1014
+ }));
1015
+ }
1016
+
1017
+ function somePage() {
1018
+ return {
1019
+ url,
1020
+ title: 'Some article',
1021
+ status: 'complete',
1022
+ pageLoadMethod: 'full-page-load',
1023
+ preDoublefetch: {
1024
+ title: 'Some article',
1025
+ url,
1026
+ noindex: false,
1027
+ meta: {},
1028
+ },
1029
+ aggregator: { activity: 0.1 },
1030
+ };
1031
+ }
1032
+
1033
+ beforeEach(function () {
1034
+ numDownloads = 0;
1035
+ fetchStub = sinon.stub(globalThis, 'fetch');
1036
+ uut = new DoublefetchPageHandler({
1037
+ jobScheduler,
1038
+ sanitizer,
1039
+ newPageApprover,
1040
+ });
1041
+ });
1042
+
1043
+ afterEach(function () {
1044
+ fetchStub.restore();
1045
+ });
1046
+
1047
+ it('should download a page that is smaller than the download limit', async function () {
1048
+ mockServerResponse({ contentLength: uut.downloadLimit - 1 });
1049
+
1050
+ await uut.runJob(somePage());
1051
+ expect(numDownloads).to.eql(1);
1052
+ });
1053
+
1054
+ it('should not download a page that is bigger than the download limit', async function () {
1055
+ mockServerResponse({ contentLength: uut.downloadLimit + 1 });
1056
+
1057
+ const { ok, details } = await uut.runJob(somePage());
1058
+ expect(ok).to.be.false;
1059
+ expect(details).to.include('Exceeded size limit');
1060
+ expect(numDownloads).to.eql(0);
1061
+ });
1062
+ });
993
1063
  });
994
1064
 
995
1065
  describe('#titlesMatchAfterDoublefetch', function () {