sorrycc / sorrycc/test

parseDuration accepts garbage input instead of throwing

Open Beginner friendly
#12 3 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.