Skip to content

Commit

Permalink
Resolve #25: Fix regex to allow 0s in the tens place of the seconds f…
Browse files Browse the repository at this point in the history
…or PBs
  • Loading branch information
big213 committed Aug 19, 2021
1 parent 19f5e8a commit 43444b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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+$/)) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/models/personalBest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const PersonalBest = <RecordInfo<'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) ||
Expand All @@ -130,7 +130,7 @@ export const PersonalBest = <RecordInfo<'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.
Expand Down

0 comments on commit 43444b8

Please sign in to comment.