Skip to content

Commit 3747f87

Browse files
committed
Fix a Windows quirk
> test result: FAILED. 640 passed; 73 failed; 0 ignored; 0 measured
1 parent 8e06270 commit 3747f87

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/parser.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,13 @@ impl<'a> Parser<'a> {
523523
self.serialization.push_str("file:///");
524524
let scheme_end = "file".len() as u32;
525525
let path_start = "file://".len();
526-
if let Some(base_url) = base_file_url {
527-
let first_segment = base_url.path_segments().unwrap().next().unwrap();
528-
// FIXME: *normalized* drive letter
529-
if is_windows_drive_letter(first_segment) {
530-
self.serialization.push_str(first_segment);
531-
self.serialization.push('/');
526+
if !starts_with_windows_drive_letter_segment(&input_after_first_char) {
527+
if let Some(base_url) = base_file_url {
528+
let first_segment = base_url.path_segments().unwrap().next().unwrap();
529+
if is_normalized_windows_drive_letter(first_segment) {
530+
self.serialization.push_str(first_segment);
531+
self.serialization.push('/');
532+
}
532533
}
533534
}
534535
let remaining = self.parse_path(
@@ -1343,6 +1344,10 @@ pub fn to_u32(i: usize) -> ParseResult<u32> {
13431344
}
13441345
}
13451346

1347+
fn is_normalized_windows_drive_letter(segment: &str) -> bool {
1348+
is_windows_drive_letter(segment) && segment.as_bytes()[1] == b':'
1349+
}
1350+
13461351
/// Wether the scheme is file:, the path has a single segment, and that segment
13471352
/// is a Windows drive letter
13481353
fn is_windows_drive_letter(segment: &str) -> bool {

0 commit comments

Comments
 (0)