mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
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:
+3
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user