diff --git a/app/src/EvalLogSearch/utils/trimEvalLogSearchForm.ts b/app/src/EvalLogSearch/utils/trimEvalLogSearchForm.ts index 31c3cdd0..f05d3177 100644 --- a/app/src/EvalLogSearch/utils/trimEvalLogSearchForm.ts +++ b/app/src/EvalLogSearch/utils/trimEvalLogSearchForm.ts @@ -3,12 +3,24 @@ import type { EvalLogSearchForm } from '@/EvalLogSearch/components/EvalLogSearch export const trimEvalLogSearchForm = ( form: EvalLogSearchForm, ): EvalLogSearchForm => { - const { projectName, corrector, corrected } = form; - - return { - ...form, - projectName: projectName?.trim() ?? undefined, - corrector: corrector?.trim() ?? undefined, - corrected: corrected?.trim() ?? undefined, - }; + const { projectName, corrector, corrected, ...rest } = form; + + const newForm: EvalLogSearchForm = { ...rest }; + + const trimmedProjectName = projectName?.trim(); + if (projectName) { + newForm.projectName = trimmedProjectName; + } + + const trimmedCorrector = corrector?.trim(); + if (corrector) { + newForm.corrector = trimmedCorrector; + } + + const trimmedCorrected = corrected?.trim(); + if (corrected) { + newForm.corrected = trimmedCorrected; + } + + return newForm; };