Repository navigation
fix(direct_url): parse URL scheme case-insensitively when checking for file URLs - #1240
Merged
Merged
Conversation
âĶr file URLs
Per RFC 3986 §3.1, URI schemes are case-insensitive, so FILE:// and
File:// are valid file URLs and must be accepted when dir_info is present.
The previous startswith("file://") check also incorrectly rejected the
RFC 8089 minimal form file:/path (single slash, no authority component).
Replace the prefix test with urllib.parse.urlsplit().scheme, which
already normalises the scheme to lowercase, covering both issues.
Assisted-by: ClaudeCode:claude-sonnet-4-6
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.
Looks correct to me.
ðĪ AI text below ðĪ
Part of #1239
Summary
not direct_url.url.startswith("file://")inDirectUrl._from_dict()incorrectly rejected valid file URLs whose scheme used different casing (e.g.FILE:///path,File:///path), violating RFC 3986 §3.1 which states URI schemes are case-insensitive.file:/path(single slash, no authority), which is a conformant file URL.urllib.parse.urlsplit(url).scheme != "file".urlsplitalready normalises the scheme to lowercase, so a single comparison handles all valid forms while still rejecting non-file schemes.FILE://,File://, andfile:/variants, plus confirmation that a non-file scheme (https://) still fails.Test plan
uv run python -m pytest tests/test_direct_url.py -qâ all 40 tests passprek -a --quietâ no lint or type errorsðĪ Generated with Claude Code