Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2830-1788932215
Open

fix: implement missing utilities and fix edge-case bugs#326
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2830-1788932215

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across 5 source files. All 60 tests now pass; no test files were modified and no dependencies were added.

Changes

  • src/calculator.tsdivide now throws on division by zero instead of returning Infinity.
  • src/string-utils.tswordCount collapses consecutive whitespace (splits on \s+ after trim). truncate implemented: truncates at a word boundary with "..." counting toward maxLength, returns unchanged when str.length <= maxLength, and handles short/edge inputs.
  • src/task-manager.ts — implemented remove (true/false on found), update (partial title/description/priority, false for unknown id), and sortBy (priority high>medium>low, createdAt oldest-first, status workflow order). sortBy sorts a copy and does not mutate internal state.
  • src/date-utils.tsformatRelative now rounds days instead of flooring, so 36h reads "2 days ago".
  • src/validator.tsisEmail accepts long TLDs (bound widened to DNS label limit {2,63}) while still rejecting empty labels; isUrl accepts URLs with ports, keeping the http/https protocol allow-list.

Assumptions

  • Expected behaviour was derived from the existing test files; no test was modified.
  • sortBy("status") uses the workflow order pending -> in_progress -> completed (no explicit test asserts this ordering, chosen as the natural default).

Security note

isUrl validates scheme only. If ever used to gate a server-side fetch it is not sufficient SSRF protection on its own — http://localhost:3000 and link-local addresses pass. A host allow-list / private-range block at the call site would be needed for that use case.

Verification

bun test -> 60 pass, 0 fail. tsc --noEmit clean.

- calculator: divide now throws on division by zero instead of returning Infinity
- string-utils: wordCount collapses consecutive whitespace; implement truncate at word boundary with ellipsis counting toward maxLength
- task-manager: implement remove, update, and sortBy (priority/createdAt/status)
- date-utils: formatRelative rounds days instead of flooring (36h => 2 days ago)
- validator: isEmail accepts long TLDs; isUrl accepts URLs with ports
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