fix: handle Windows file:// URL with three slashes in resolve_dir#4497
Closed
1795771535y-cell wants to merge 1 commit into
Closed
fix: handle Windows file:// URL with three slashes in resolve_dir#44971795771535y-cell wants to merge 1 commit into
1795771535y-cell wants to merge 1 commit into
Conversation
When file:// URL is canonicalized, it becomes file:///C:/path on
Windows. The fallback strip_prefix("file://") left a leading slash,
producing an invalid path /C:/repos/... on Windows.
Try stripping file:/// first, then fall back to file://.
Closes #4104
bbbd142 to
6370370
Compare
Author
|
Closing: no maintainer response after extended wait. Thanks for the opportunity. |
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.
Problem
When a file:// URL is canonicalized by RepositoryConfig::canonicalize_url(), it becomes file:///C:/path on Windows (three slashes per RFC 8089). The fallback strip_prefix("file://") in resolve_dir() leaves a leading slash, producing /C:/repos/... which is invalid on Windows. This causes scheduled index jobs to fail with "Directory does not exist".
Steps to reproduce:
Fix
Try strip_prefix("file:///") first (three slashes for absolute paths), then fall back to strip_prefix("file://") (two slashes for relative/host-based paths). This correctly handles both canonicalized and raw Windows file:// URLs.
Testing
The existing test suite covers both formats. No test changes needed as existing ile:///C:/ test cases already produce the correct PathBuf.
Closes #4104