From 0e59e55582ea8147b6a3770ca7b91abb2b8ace65 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:28:35 -0400 Subject: [PATCH] fix bug in canonicalizing `#{intl::foo::hash}` Co-Authored-By: sadan4 <117494111+sadan4@users.noreply.github.com> --- src/utils/patches.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/patches.ts b/src/utils/patches.ts index 53cf05dbc..70f1f3b5d 100644 --- a/src/utils/patches.ts +++ b/src/utils/patches.ts @@ -22,10 +22,10 @@ import { Patch, PatchReplacement, ReplaceFn } from "./types"; export function canonicalizeMatch(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) {