test: add unit coverage for bin/utils/url.ts helpers#1279
Open
LuisMIguelFurlanettoSousa wants to merge 1 commit into
Open
test: add unit coverage for bin/utils/url.ts helpers#1279LuisMIguelFurlanettoSousa wants to merge 1 commit into
LuisMIguelFurlanettoSousa wants to merge 1 commit into
Conversation
bin/utils/url.ts had no dedicated test file; getDomain, appendProtocol, and normalizeUrl were untested (only safeDomainsToRegex is covered, via safe-domains.test.ts). Add tests/unit/url.test.ts characterizing the SLD extraction (incl. multi-part public suffixes and single-label hosts), the add-https behavior of appendProtocol (including the WHATWG host:port quirk), and normalizeUrl, covering its previously-untested throw branch.
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.
Closes #1278
What
Adds
tests/unit/url.test.ts, the first dedicated test file forbin/utils/url.ts. Previously onlysafeDomainsToRegexwas covered (viasafe-domains.test.ts);getDomain,appendProtocol, andnormalizeUrlwere untested.Coverage
getDomain— bare domain,www/arbitrary subdomain stripping, multi-part public suffixes (example.co.uk), and thenullpaths (no protocol, malformed input, single-labellocalhost).appendProtocol— already-schemed URLs pass through; bare host getshttps://; and the documented WHATWG quirk wherelocalhost:3000is parsed as schemelocalhost:and left unchanged.normalizeUrl— bare host normalization, valid URL passthrough, and the previously-uncovered throw branch.Tests only — no change to
bin/, so nodist/cli.jsrebuild. All assertions characterize current behavior (verified against the live functions).Verify
Full suite: 218 passed;
pnpm run format:checkclean.