@duckduckgo/autoconsent 16.8.0 → 16.8.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.
@@ -47,6 +47,18 @@ describe('checkHeuristicPatterns', () => {
47
47
  expect(patterns).to.have.length(0);
48
48
  expect(snippets).to.have.length(0);
49
49
  });
50
+
51
+ it('handles non-global regex with optional capture groups without throwing', () => {
52
+ // Regex from heuristic-patterns.ts (Polish) that has optional capture groups and
53
+ // no `g` flag. `String.prototype.match` returns `undefined` entries for optional
54
+ // groups that did not match, which used to crash the caller with a TypeError.
55
+ const pattern = /(używamy|stosujemy)( są)?.{0,20} plik(i|ów|ach) cookie/i;
56
+ const { patterns, snippets } = checkHeuristicPatterns('Używamy plików cookie i innych technologii', [pattern]);
57
+
58
+ expect(patterns.length).to.be.greaterThan(0);
59
+ expect(snippets.length).to.be.greaterThan(0);
60
+ expect(snippets.every((s) => typeof s === 'string')).to.be.true;
61
+ });
50
62
  });
51
63
 
52
64
  describe('cleanButtonText', () => {