Skip to content

fix: implement missing utilities and fix edge-case bugs - #270

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2279-1785342901
Open

fix: implement missing utilities and fix edge-case bugs#270
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2279-1785342901

Conversation

@stooit

@stooit stooit commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests in the utility library. The suite is now 60 pass / 0 fail, and tsc --noEmit is clean. No test files were modified and no dependencies were added.

Changes

  • calculator (src/calculator.ts) — divide now throws on division by zero.
  • string-utils (src/string-utils.ts) — implemented truncate (cuts at a word boundary, with "..." counting toward maxLength, returns unchanged when str.length <= maxLength, and safely handles very short strings); fixed wordCount to collapse consecutive whitespace.
  • task-manager (src/task-manager.ts) — implemented remove, update, and sortBy (priority high>medium>low; createdAt oldest-first).
  • date-utils (src/date-utils.ts) — fixed off-by-one in formatRelative (rounding hours instead of flooring).
  • validator (src/validator.ts) — isEmail accepts long TLDs; isUrl accepts URLs with a port.

Verification

  • bun test → 60 pass / 0 fail (70 assertions)
  • bunx tsc --noEmit → clean

Review notes

A review pass confirmed all fixes correct with no regressions. The flagged isEmail regex was tested for ReDoS and found to be linear (not vulnerable), and CRLF-injection payloads are rejected. Non-blocking hardening suggestions were raised (SSRF docstring caveat on isUrl, stricter local-part rules on isEmail) but are out of scope here — the task was to fix only what the tests require.

Assumptions

  • Behaviour was driven strictly by existing test expectations; no behavioural changes beyond what tests specify.

Fixes 16 failing tests across the utility library:
- calculator: divide now throws on division by zero
- string-utils: implement truncate (word-boundary + ellipsis); fix
  wordCount to handle consecutive whitespace
- task-manager: implement remove, update, and sortBy (priority,
  createdAt) methods
- date-utils: fix off-by-one in formatRelative (round vs floor on hours)
- validator: allow long TLDs in isEmail; accept ports in isUrl
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.

1 participant