Skip to content

Commit abd907a

Browse files
authored
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
1 parent 96351c4 commit abd907a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/rules.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ function edit(regex: string | RegExp, opt = '') {
1616
return obj;
1717
}
1818

19-
const supportsLookbehind = (() => {
19+
// use a default variable to ensure the regex is evaluated on client an not removed by minifiers
20+
const supportsLookbehind = ((a = '') => {
2021
try {
21-
// eslint-disable-next-line prefer-regex-literals
22-
return !!new RegExp('(?<=1)(?<!1)');
22+
return !!new RegExp('(?<=1)(?<!1)' + a);
2323
} catch {
2424
// See browser support here:
2525
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion

0 commit comments

Comments
 (0)