From 44f1926a044e3d83df57b5e3eefc2a5abeeaeb81 Mon Sep 17 00:00:00 2001 From: Michael Moore Date: Tue, 28 May 2024 12:24:11 -0500 Subject: [PATCH] fix(map): fix failed map renders when names contain color codes --- src/renderer/src/lib/map/data/locUtils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/lib/map/data/locUtils.ts b/src/renderer/src/lib/map/data/locUtils.ts index 5803513..b841936 100644 --- a/src/renderer/src/lib/map/data/locUtils.ts +++ b/src/renderer/src/lib/map/data/locUtils.ts @@ -41,7 +41,7 @@ export function localizeTextSync( } } let value = loc[text.key]; - if (value == null) return text.key; + if (value == null) return removeColorCodes(text.key); if (text.variables) { text.variables.forEach((variable) => { const localizedVariable = localizeTextSync(variable.value, loc); @@ -51,5 +51,9 @@ export function localizeTextSync( .replace(`<${variable.key}>`, localizedVariable); }); } - return value; + return removeColorCodes(value); +} + +function removeColorCodes(text: string): string { + return text.replace(/[\u0011ยง]./g, ''); // eslint-disable-line no-control-regex }