From 43444b8e8f9750507bf1c0b4b2af6da8e63bedb9 Mon Sep 17 00:00:00 2001 From: big213 Date: Wed, 18 Aug 2021 22:56:05 -0400 Subject: [PATCH] Resolve #25: Fix regex to allow 0s in the tens place of the seconds for PBs --- .../interface/crud/special/editPersonalBestInterface.vue | 2 +- frontend/models/personalBest.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/components/interface/crud/special/editPersonalBestInterface.vue b/frontend/components/interface/crud/special/editPersonalBestInterface.vue index 594ef5d..5828198 100644 --- a/frontend/components/interface/crud/special/editPersonalBestInterface.vue +++ b/frontend/components/interface/crud/special/editPersonalBestInterface.vue @@ -165,7 +165,7 @@ export default { if (!val) return // if pasted value matches the correct format, don't do anything - if (val.match(/^(\d+:)?([0-5]?\d:)?[1-5]?\d\.\d{2}$/)) return + if (val.match(/^(\d+:)?([0-5]?\d:)?[0-5]?\d\.\d{2}$/)) return // if val is 1 or more digits only, parse if (val.match(/^\d+$/)) { diff --git a/frontend/models/personalBest.ts b/frontend/models/personalBest.ts index 0baf1bc..1106d8a 100644 --- a/frontend/models/personalBest.ts +++ b/frontend/models/personalBest.ts @@ -118,7 +118,7 @@ export const PersonalBest = >{ hint: 'Type in the numbers only, the numbers will be auto-formatted', inputRules: [ (value) => { - const regEx = /^(\d+:)?([0-5]?\d:)?[1-5]?\d\.\d{2}$/ + const regEx = /^(\d+:)?([0-5]?\d:)?[0-5]?\d\.\d{2}$/ return ( !value || regEx.test(value) || @@ -130,7 +130,7 @@ export const PersonalBest = >{ parseValue: (value) => { if (!value) return null if (typeof value !== 'string') throw new Error('Invalid value') - const regEx = /^(\d+:)?([0-5]?\d:)?[1-5]?\d\.\d{2}$/ + const regEx = /^(\d+:)?([0-5]?\d:)?[0-5]?\d\.\d{2}$/ if (!regEx.test(value)) throw new Error('Invalid value') // convert string to number of ms.