fix bug in canonicalizing #{intl::foo::hash}
Co-Authored-By: sadan4 <117494111+sadan4@users.noreply.github.com>
This commit is contained in:
parent
ffbb6b1960
commit
0e59e55582
1 changed files with 3 additions and 3 deletions
|
|
@ -22,10 +22,10 @@ import { Patch, PatchReplacement, ReplaceFn } from "./types";
|
|||
export function canonicalizeMatch<T extends RegExp | string>(match: T): T {
|
||||
let partialCanon = typeof match === "string" ? match : match.source;
|
||||
partialCanon = partialCanon.replaceAll(/#{intl::([\w$+/]*)(?:::(\w+))?}/g, (_, key, modifier) => {
|
||||
const hashed = modifier === "raw" ? key : runtimeHashMessageKey(key);
|
||||
if (modifier === "hash") return hashed;
|
||||
|
||||
const isString = typeof match === "string";
|
||||
const hashed = modifier === "raw" ? key : runtimeHashMessageKey(key);
|
||||
if (modifier === "hash") return isString ? hashed : String.raw`(?:${hashed})`.replaceAll("+", "\\+");
|
||||
|
||||
const hasSpecialChars = !Number.isNaN(Number(hashed[0])) || hashed.includes("+") || hashed.includes("/");
|
||||
|
||||
if (hasSpecialChars) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue