From 7b35cf0abfe87e3ea2ccdd25e4406cb78c0a2fc2 Mon Sep 17 00:00:00 2001 From: Abhinav Raut Date: Mon, 28 Apr 2025 01:47:23 +0530 Subject: [PATCH] fix: improve regex validation for go duration --- frontend/src/utils/strings.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/strings.js b/frontend/src/utils/strings.js index 056c8790..8e17b8e4 100644 --- a/frontend/src/utils/strings.js +++ b/frontend/src/utils/strings.js @@ -37,7 +37,8 @@ export function validateEmail (email) { } export const isGoDuration = (value) => { - const regex = /^[0-9]+[smh]$/ + if (value === '') return false + const regex = /^(\d+h)?(\d+m)?(\d+s)?$/ return regex.test(value) } @@ -59,7 +60,7 @@ export function getTextFromHTML (htmlString) { } } -export function getInitials(firstName = '', lastName = '') { +export function getInitials (firstName = '', lastName = '') { const firstInitial = firstName.charAt(0).toUpperCase() || '' const lastInitial = lastName.charAt(0).toUpperCase() || '' return `${firstInitial}${lastInitial}`