Skip to content

Commit

Permalink
cleanup competition name
Browse files Browse the repository at this point in the history
  • Loading branch information
nimarion committed Aug 9, 2024
1 parent d13f309 commit 861d1a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/athletes/athlete.zod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cleanupMark, formatLastname } from 'src/utils';
import { cleanupCompetitionName, cleanupMark, formatLastname } from 'src/utils';
import { z } from 'zod';

export const BirthdateSchema = z
Expand Down Expand Up @@ -51,7 +51,7 @@ export const WindSchema = z

export const CompetitionSchema = z
.string()
.transform((val) => val.replace(' (i)', ''));
.transform((val) => cleanupCompetitionName(val));

export const DateSchema = z.string().transform((val) => {
const date = new Date(val);
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export function cleanupMark(mark: string): string {
return mark.replace(/[^0-9:.]/g, '');
}

export function cleanupCompetitionName(competitionName: string) {
return competitionName.replace(' (i)', '').split(',')[0];
}

export function isShortTrack(discipline: string): boolean {
return discipline.endsWith('Short Track');
}
Expand Down

0 comments on commit 861d1a5

Please sign in to comment.