#83 - Use non-capturing optional group, add tests and update dist

This commit is contained in:
Michal Dorner 2021-03-23 21:39:47 +01:00
parent c0e7f7f7dc
commit 3a0bb833dc
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
4 changed files with 40 additions and 5 deletions

View file

@ -1,6 +1,5 @@
export function parseNetDuration(str: string): number {
// matches dotnet duration: 00:00:00.0010000
const durationRe = /^(\d\d):(\d\d):(\d\d($|\.\d+$))/
const durationRe = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)$/
const durationMatch = str.match(durationRe)
if (durationMatch === null) {
throw new Error(`Invalid format: "${str}" is not NET duration`)