fix(rules): ensure lookbehind regex is evaluated correctly by minifiers (#3945)

* fix(rules): ensure lookbehind regex is evaluated correctly by minifiers

* Use a default variable in the regex to prevent removal by minifiers

* fix(rules): remove unnecessary eslint directive for lookbehind regex
This commit is contained in:
christophe geiser
2026-04-16 21:11:49 -06:00
committed by GitHub
parent 96351c4a22
commit abd907aab5
+3 -3
View File
@@ -16,10 +16,10 @@ function edit(regex: string | RegExp, opt = '') {
return obj;
}
const supportsLookbehind = (() => {
// use a default variable to ensure the regex is evaluated on client an not removed by minifiers
const supportsLookbehind = ((a = '') => {
try {
// eslint-disable-next-line prefer-regex-literals
return !!new RegExp('(?<=1)(?<!1)');
return !!new RegExp('(?<=1)(?<!1)' + a);
} catch {
// See browser support here:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion