fix: shorten current match server display name

This commit is contained in:
devRaGonSa
2026-05-21 17:09:40 +02:00
parent 45801bb955
commit 2c614982b3

View File

@@ -80,7 +80,8 @@ async function loadKillFeed({ backendBaseUrl, serverSlug, nodes, killFeedState }
}
function renderCurrentMatch(data, nodes) {
const serverName = data.server_name || data.server_slug || "Servidor no disponible";
const rawServerName = data.server_name || data.server_slug || "Servidor no disponible";
const serverName = formatServerDisplayName(data, rawServerName);
const mapName = data.map_pretty_name || data.map || "Mapa no disponible";
const scoreboardUrl = resolveTrustedScoreboardUrl(data);
nodes.title.textContent = mapName;
@@ -349,6 +350,21 @@ function resolveTrustedScoreboardUrl(data) {
return data.public_scoreboard_url === trustedUrl ? trustedUrl : "";
}
function formatServerDisplayName(data, fallbackName) {
const trustedName = CURRENT_MATCH_SERVERS[data.server_slug];
if (trustedName) {
return trustedName;
}
const normalized = String(fallbackName || "").trim();
const serverNumber = normalized.match(/^#0?([1-9])\b/);
if (serverNumber) {
return `Comunidad Hispana #${serverNumber[1].padStart(2, "0")}`;
}
return normalized || "Servidor no disponible";
}
function hasKnownScore(data) {
return isNumericValue(data.allied_score) && isNumericValue(data.axis_score);
}