From bda1d796b0838be6a1caf4c32dd01e32142041d4 Mon Sep 17 00:00:00 2001 From: Stan Runge Date: Tue, 10 Mar 2026 03:44:44 +0100 Subject: [PATCH] allow fo rboth cols directions --- .../(app)/mappools/[id]/+page.server.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/routes/(app)/mappools/[id]/+page.server.ts b/src/routes/(app)/mappools/[id]/+page.server.ts index faacc8e..6b6984d 100644 --- a/src/routes/(app)/mappools/[id]/+page.server.ts +++ b/src/routes/(app)/mappools/[id]/+page.server.ts @@ -305,15 +305,26 @@ export const actions: Actions = { continue; } - const modCode = parts[0]; - const modMatch = modCode.match(/^(NM|HD|HR|DT|FM|TB)\d*$/i); - if (!modMatch) { - errors.push(`Line ${lineNum}: unknown mod "${modCode}"`); + // Detect column order: mod+id or id+mod + const modRegex = /^(NM|HD|HR|DT|FM|TB)\d*$/i; + let modCode: string; + let beatmapRaw: string; + + if (modRegex.test(parts[0])) { + modCode = parts[0]; + beatmapRaw = parts[1]; + } else if (modRegex.test(parts[parts.length - 1])) { + modCode = parts[parts.length - 1]; + beatmapRaw = parts[0]; + } else { + errors.push(`Line ${lineNum}: no valid mod code found`); continue; } + + const modMatch = modCode.match(modRegex)!; const category = modMatch[1].toUpperCase(); - let beatmapId = parts[1]; + let beatmapId = beatmapRaw; const urlMatch = beatmapId.match(/beatmaps\/(\d+)/); const setMatch = beatmapId.match(/beatmapsets\/\d+#\w+\/(\d+)/); const shortMatch = beatmapId.match(/\/b\/(\d+)/);