Skip to content

fix: implement missing utilities and correct edge-case bugs - #303

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2216-1787674597
Open

fix: implement missing utilities and correct edge-case bugs#303
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2216-1787674597

Conversation

@stooit

@stooit stooit commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests in the utility library. bun test now reports 60 pass / 0 fail (was 44/16) and npx tsc --noEmit is clean. No test files, config, or dependencies were touched — only src/.

Changes

File Change
calculator.ts divide throws on b === 0 (was returning Infinity)
string-utils.ts wordCount trims then splits on /\s+/; truncate implemented with word-boundary cut
task-manager.ts remove (Map.delete), update (per-field !== undefined guards), sortBy (typed rank maps with an explicit id tie-break)
date-utils.ts day count now Math.round(abs(diffHours)/24), fixing an off-by-one
validator.ts email TLD bound {2,4}{2,} (accepts .museum); dropped the url.port === "" conjunct (accepts http://localhost:3000)

Verification

  • bun test → 60 pass, 0 fail
  • npx tsc --noEmit → clean (exit 0)
  • Diff scoped to 5 src/ files only

Assumptions & notes

  • isEmail/isUrl were intentionally loosened to satisfy the tests. They are format checks, not sanitisers — isUrl now accepts loopback/internal hosts and credentials. Docblocks note this so the relaxation isn't mistaken for a security control; any server-side-fetch consumer needs its own allowlist (SSRF).
  • update() guards each field with !== undefined, so passing undefined is a no-op rather than clearing a field. Flagged in review as a possible follow-up if explicit clearing is ever needed.
  • Pre-existing (out of scope): formatRelative has a minor discontinuity in the sub-24h branch (23.5h renders as "24 hours ago"). Not introduced by this change.

Review

Reviewed by the review subagent: verdict COMMENT, no blockers. All warnings are consumer/edge concerns documented above.

Adds divide-by-zero guard, truncate and TaskManager
remove/update/sortBy implementations, and fixes wordCount
whitespace handling, relative-date day rounding, and
email/URL validation bounds.
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