parseDuration accepts garbage input instead of throwing
Open
Beginner friendly
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
The docs say invalid durations throw, but the regex is unanchored, so any string merely containing a duration segment parses:
parseDuration("x30m") // → 1800000, expected: throw "invalid duration"
parseDuration("abc 5h!") // → 18000000, expected: throw
parseDuration("-5m") // → 300000 — the sign is silently ignored
Expected: only well-formed duration strings (e.g. "2h", "30m", "1h30m") are accepted; anything else throws invalid duration.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the parseDuration entry point and its unanchored regex, then inspect any existing tests for duration parsing. Add coverage for embedded text, punctuation, and negative inputs, ensuring valid forms such as "2h" and "1h30m" still work and invalid inputs throw "invalid duration".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100