Fix badge bad name + prevent Unicode replacement characters in the check script

This commit is contained in:
Kalle 2025-11-25 20:52:52 +02:00
parent 3e128adaa4
commit 1d03ac784b
2 changed files with 10 additions and 2 deletions

View File

@ -1204,7 +1204,7 @@
"authorDiscordId": "338806780446638082"
},
"torneoes": {
"displayName": "PEÑA Tournament",
"displayName": "PEÑA Tournament",
"authorDiscordId": "752582395076673577"
},
"tralalero": {

View File

@ -35,7 +35,7 @@ for (const key of Object.keys(badges)) {
lastKey = key;
}
// check for duplicate displayName values
// check for duplicate displayName values and encoding issues
const displayNames = new Map<string, string>();
for (const [key, badge] of Object.entries(badges)) {
const existingKey = displayNames.get(badge.displayName);
@ -46,6 +46,14 @@ for (const [key, badge] of Object.entries(badges)) {
process.exit(1);
}
displayNames.set(badge.displayName, key);
// check for Unicode replacement characters (encoding issues)
if (badge.displayName.includes("\uFFFD")) {
console.error(
`Invalid encoding in displayName for badge "${key}": contains replacement character (<28>). This usually means the file was saved with incorrect encoding.`,
);
process.exit(1);
}
}
// check each key has the 3 matching files in the right location