diff --git a/platform/npm/tests/snfe.js b/platform/npm/tests/snfe.js index f0ee86b57..b1cee181c 100644 --- a/platform/npm/tests/snfe.js +++ b/platform/npm/tests/snfe.js @@ -341,6 +341,31 @@ describe('SNFE', () => { }); assert.strictEqual(r, 0); }); + + // https://github.com/AdguardTeam/AdguardFilters/issues/88067#issuecomment-1019518277 + it('should match regex-based filter without `match-case` option', async () => { + await engine.useLists([ + { name: 'test', raw: '/\.com\/[a-z]{9,}\/[a-z]{9,}\.js$/$script,1p' }, + ]); + const r = engine.matchRequest({ + originURL: 'https://example.com/', + type: 'script', + url: 'https://example.com/LQMDQSMLDAZAEHERE/LQMDQSMLDAZAEHERE.js', + }); + assert.strictEqual(r, 1); + }); + + it('should not match regex-based filter with `match-case` option', async () => { + await engine.useLists([ + { name: 'test', raw: '/\.com\/[a-z]{9,}\/[a-z]{9,}\.js$/$script,1p,match-case' }, + ]); + const r = engine.matchRequest({ + originURL: 'https://example.com/', + type: 'script', + url: 'https://example.com/LQMDQSMLDAZAEHERE/LQMDQSMLDAZAEHERE.js', + }); + assert.strictEqual(r, 0); + }); }); }); } diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index e96bb8b82..f28c6ca10 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -1108,7 +1108,7 @@ const FilterRegex = class { if ( refs.$re === null ) { refs.$re = new RegExp( this.getRegexPattern(idata), - filterData[idata+3] === 0 ? '' : 'i' + filterData[idata+3] === 0 ? 'i' : '' ); } if ( refs.$re.test($requestURLRaw) === false ) { return false; }