PatchHelper: Fix incorrect escape handling (#3194)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
746f31e412
commit
fcb8276a81
1 changed files with 5 additions and 1 deletions
|
|
@ -40,7 +40,11 @@ export function canonicalizeMatch<T extends RegExp | string>(match: T): T {
|
|||
return partialCanon as T;
|
||||
}
|
||||
|
||||
const canonSource = partialCanon.replaceAll("\\i", String.raw`(?:[A-Za-z_$][\w$]*)`);
|
||||
const canonSource = partialCanon.replaceAll(/(\\*)\\i/g, (match, leadingEscapes) =>
|
||||
leadingEscapes.length % 2 === 0
|
||||
? `${leadingEscapes}${String.raw`(?:[A-Za-z_$][\w$]*)`}`
|
||||
: match.slice(1)
|
||||
);
|
||||
const canonRegex = new RegExp(canonSource, match.flags);
|
||||
canonRegex.toString = match.toString.bind(match);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue