diff --git a/app/lib/__tests__/parse-results-text.test.ts b/app/lib/__tests__/parse-results-text.test.ts index 380115b..496933e 100644 --- a/app/lib/__tests__/parse-results-text.test.ts +++ b/app/lib/__tests__/parse-results-text.test.ts @@ -8,6 +8,12 @@ describe("parseResultsText", () => { { placement: 1, rawName: "Gerwyn Price" }, ]); }); + + it("parses '1.Player Name' (no space after dot)", () => { + expect(parseResultsText("1.Gerwyn Price")).toEqual([ + { placement: 1, rawName: "Gerwyn Price" }, + ]); + }); }); describe("comma separator", () => { diff --git a/app/lib/parse-results-text.ts b/app/lib/parse-results-text.ts index a30b4ae..8723f31 100644 --- a/app/lib/parse-results-text.ts +++ b/app/lib/parse-results-text.ts @@ -27,7 +27,7 @@ export function parseResultsText(text: string): ParsedLine[] { // Try to match: optional T, digits, optional separator (. or ,), then whitespace and the name // Pattern 1: "1. Name", "1, Name", "T3. Name", "T3, Name" - const match = line.match(/^[Tt]?(\d+)[.,]\s+(.+)$/); + const match = line.match(/^T?(\d+)[.,]\s*(.+)$/); if (match) { results.push({ placement: parseInt(match[1], 10), @@ -37,7 +37,7 @@ export function parseResultsText(text: string): ParsedLine[] { } // Pattern 2: "1 Name", "T3 Name" (space-only separator) - const spaceMatch = line.match(/^[Tt]?(\d+)\s+(.+)$/); + const spaceMatch = line.match(/^T?(\d+)\s+(.+)$/); if (spaceMatch) { results.push({ placement: parseInt(spaceMatch[1], 10),