You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(parseURL): anchor Windows file path normalization - #413
File URL parsing currently removes the first slash before a drive-like segment anywhere in the path, query, or fragment. For example, parseURL("file:///tmp/C:/file.txt").pathname returns "/tmpC:/file.txt", and ?next=/C:/data becomes ?next=C:/data.
Anchor the existing normalization pattern to the start of the path so nested path segments, queries, and fragments retain their slashes. Add eight cases covering these regressions and the existing leading Windows drive behavior.
Validation
Six new cases fail against unchanged main; the two Windows drive controls pass.
corepack pnpm test: all 499 tests pass, including lint, formatting, and type checks.
corepack pnpm build: passes.
Built ESM and CommonJS outputs match native URL for the six affected inputs and round-trip through stringifyParsedURL.
git diff --check: passes.
Summary by CodeRabbit
Bug Fixes
Corrected parsing of file: URLs so slashes are removed only when they immediately precede a drive-letter path. Query strings and fragments are preserved correctly, including for localhost and server-share URLs.
No actionable comments were generated in the recent review.
Walkthrough
parseURL now removes a slash before a drive letter only when the slash is at the start of a file: URL path. Tests cover drive-like segments in the pathname, query, and fragment.
Changes: File URL parsing
Layer / File(s)
Summary
Drive-path parsing and regression cases src/parse.ts, test/parse.test.ts
The drive-prefix slash adjustment applies only at the start of the path. Eight test cases check that drive-like segments remain assigned to the expected pathname, search, and hash components.
unjs/ufo#412 — Both PRs change the file: drive-letter adjustment in parseURL, covering the protocol check and the slash-removal condition.
Merge Risk: Minimal · up to 2e385
The change narrows drive-path normalization; no merge-blocking risk is identified.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the parseURL function and the Windows file path normalization. The change limits removal of the leading slash before a drive-letter path to the start of the file URL path, so the title…
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the parseURL function and the Windows file path normalization. The change limits removal of the leading slash before a drive-letter path to the start of the file URL path, so the title matches the main change. The title uses a conventional fix(...) prefix and is concise, although "anchor" is slightly technical. It is clear enough for a teammate scanning history to understand the primary change.
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: ff8a389e-6711-43e5-badf-10475d195426
Commits
Reviewing files that changed from the base of the PR and between f06c800 and 2e38511.
Files selected for processing: 2
src/parse.ts
test/parse.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
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
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.
File URL parsing currently removes the first slash before a drive-like segment anywhere in the path, query, or fragment. For example,
parseURL("file:///tmp/C:/file.txt").pathnamereturns"/tmpC:/file.txt", and?next=/C:/databecomes?next=C:/data.Anchor the existing normalization pattern to the start of the path so nested path segments, queries, and fragments retain their slashes. Add eight cases covering these regressions and the existing leading Windows drive behavior.
Validation
corepack pnpm test: all 499 tests pass, including lint, formatting, and type checks.corepack pnpm build: passes.URLfor the six affected inputs and round-trip throughstringifyParsedURL.git diff --check: passes.Summary by CodeRabbit
file:URLs so slashes are removed only when they immediately precede a drive-letter path. Query strings and fragments are preserved correctly, including for localhost and server-share URLs.