Skip to content

Allow multiple whitespace characters between a value and its unit#71

Merged
dy merged 1 commit into
jkroso:masterfrom
spokodev:fix/whitespace-between-value-and-unit
Jul 8, 2026
Merged

Allow multiple whitespace characters between a value and its unit#71
dy merged 1 commit into
jkroso:masterfrom
spokodev:fix/whitespace-between-value-and-unit

Conversation

@spokodev

@spokodev spokodev commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

The regex allows only a single optional whitespace between a value and its unit (\s?), so any input with more than one space drops the unit and the number falls back to the default:

parse('5  s')   // 5   (expected 5000)
parse('10   m') // 10  (expected 600000)

The pattern used \s* here until the quantifiers were bounded for ReDoS safety, which incidentally reduced it to \s?. Restoring \s* is safe: \s and \p{L} are disjoint character classes and the numeric part is bounded, so matching stays linear (a 200 KB input parses in a few ms).

@dy
dy merged commit 5425d06 into jkroso:master Jul 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants