From 861d1a53ecafbc8f43df7395d9afa0f56b5ba799 Mon Sep 17 00:00:00 2001 From: Niklas Marion Date: Fri, 9 Aug 2024 09:49:00 +0200 Subject: [PATCH] cleanup competition name --- src/athletes/athlete.zod.ts | 4 ++-- src/utils.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/athletes/athlete.zod.ts b/src/athletes/athlete.zod.ts index 3c27f7b..61b1239 100644 --- a/src/athletes/athlete.zod.ts +++ b/src/athletes/athlete.zod.ts @@ -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 @@ -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); diff --git a/src/utils.ts b/src/utils.ts index ab1523c..0921fa6 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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'); }