diff --git a/typescript/server/src/lib/game-specific/custom-bms-tables.ts b/typescript/server/src/lib/game-specific/custom-bms-tables.ts index 54810fdae..9e3b37a77 100644 --- a/typescript/server/src/lib/game-specific/custom-bms-tables.ts +++ b/typescript/server/src/lib/game-specific/custom-bms-tables.ts @@ -263,20 +263,22 @@ export async function HandleBMSTableBodyRequest( /** * Normalise a level value fetched from a proxied external BMS table. * - * Rules applied in order after trimming: - * - `sub` → ` (sub)` e.g. "sub3" → "3 (sub)" - * - `` → `` e.g. "dl3" → "3" (when prefix is "dl") - * - otherwise returned as-is + * Rules applied in order (each step trims its segment so stray spaces after prefix/sub are dropped): + * - outer string is trimmed once + * - `sub` → ` (sub)` with `` trimmed, e.g. "sub 3" → "3 (sub)" + * - `` → `` trimmed, e.g. "dl 3" → "3" when prefix is "dl" + * - otherwise the trimmed outer string is returned */ function fixLetsGoTimeHellLevel(raw: number | string, prefix: string): string { const s = String(raw).trim(); + const p = prefix.trim(); if (s.startsWith("sub")) { - return `${s.slice("sub".length)} (sub)`; + return `${s.slice("sub".length).trim()} (sub)`.trim(); } - if (s.startsWith(prefix)) { - return s.slice(prefix.length); + if (p.length > 0 && s.startsWith(p)) { + return s.slice(p.length).trim(); } return s;