ui : escape sidecar tokens in the regex alternation

Assisted-by: pi:zai-org/GLM-5.3-Flash
This commit is contained in:
Aleksander Grygier
2026-09-30 12:06:42 +02:00
committed by Pascal
parent b92431df36
commit 383408a360
@@ -15,7 +15,15 @@ export const SIDECAR_TOKENS: string[] = [
/** Separator between token alternatives in the sidecar regexes. */
const REGEX_ALTERNATION_SEPARATOR = '|';
const SIDECAR_TOKEN_ALTERNATION = SIDECAR_TOKENS.join(REGEX_ALTERNATION_SEPARATOR);
/** Escape regex metacharacters so a token change cannot silently corrupt the alternation. */
function escapeRegExp(token: string): string {
return token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
const SIDECAR_TOKEN_ALTERNATION = SIDECAR_TOKENS.map(escapeRegExp).join(
REGEX_ALTERNATION_SEPARATOR
);
export const MODEL_ID = {
/**