Skip to content

Commit

Permalink
fix(map): fix failed map renders when names contain color codes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMakesGames committed May 28, 2024
1 parent affba52 commit 44f1926
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/renderer/src/lib/map/data/locUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
}

0 comments on commit 44f1926

Please sign in to comment.