fix: handle no-space after dot separator, tighten T-prefix to uppercase only
This commit is contained in:
parent
6988b8c1c0
commit
a3c6e7ab09
2 changed files with 8 additions and 2 deletions
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue