fix: implement missing utilities and correct edge-case bugs - #303
Open
stooit wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all 16 failing tests in the utility library.
bun testnow reports 60 pass / 0 fail (was 44/16) andnpx tsc --noEmitis clean. No test files, config, or dependencies were touched — onlysrc/.Changes
calculator.tsdividethrows onb === 0(was returningInfinity)string-utils.tswordCounttrims then splits on/\s+/;truncateimplemented with word-boundary cuttask-manager.tsremove(Map.delete),update(per-field!== undefinedguards),sortBy(typed rank maps with an explicitidtie-break)date-utils.tsMath.round(abs(diffHours)/24), fixing an off-by-onevalidator.ts{2,4}→{2,}(accepts.museum); dropped theurl.port === ""conjunct (acceptshttp://localhost:3000)Verification
bun test→ 60 pass, 0 failnpx tsc --noEmit→ clean (exit 0)src/files onlyAssumptions & notes
isEmail/isUrlwere intentionally loosened to satisfy the tests. They are format checks, not sanitisers —isUrlnow 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 passingundefinedis a no-op rather than clearing a field. Flagged in review as a possible follow-up if explicit clearing is ever needed.formatRelativehas a minor discontinuity in the sub-24h branch (23.5h renders as "24 hours ago"). Not introduced by this change.Review
Reviewed by the
reviewsubagent: verdict COMMENT, no blockers. All warnings are consumer/edge concerns documented above.