Skip to content

Only skip trailing-slash removal for drive letters on file: URLs#1138

Open
momomuchu wants to merge 1 commit into
servo:mainfrom
momomuchu:fix-join-drive-letter-non-file
Open

Only skip trailing-slash removal for drive letters on file: URLs#1138
momomuchu wants to merge 1 commit into
servo:mainfrom
momomuchu:fix-join-drive-letter-non-file

Conversation

@momomuchu

Copy link
Copy Markdown

last_slash_can_be_removed() refused to drop a trailing slash whenever the
previous path segment looked like a Windows drive letter (C: or C|), even
outside file: URLs. Per the spec (https://url.spec.whatwg.org/#pop-a-urls-path)
this exemption only applies when url's scheme is "file" - shorten_path and
pop_path already gate the same check on scheme_type.is_file(), this was the
one sibling that didn't.

Fixes #1130

Url::parse("abc://x/y/z/C:/").unwrap().join("..").unwrap()
// was "abc://x/y/z/C:/", now "abc://x/y/z/"

Added tests cover non-file special and non-special schemes, the C| form,
and a companion case confirming file: URLs keep the existing drive-letter
guard.

last_slash_can_be_removed() refused to drop a trailing slash whenever
the previous path segment looked like a Windows drive letter (C: or
C|), even outside file: URLs. Per the URL spec this exemption only
applies to file: URLs, matching its siblings shorten_path and
pop_path which already gate on scheme_type.is_file(). Add the same
guard so join("..") pops an ordinary segment such as "C:" for any
other scheme.

Fixes servo#1130
@momomuchu momomuchu force-pushed the fix-join-drive-letter-non-file branch from eac9a75 to f071a35 Compare July 9, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

url-constructor: '..' against a non-special base must pop the last path segment

1 participant