Skip to content

Commit 68091f7

Browse files
noxo0Ignition0o
authored andcommitted
Fix a Windows quirk
> test result: FAILED. 640 passed; 73 failed; 0 ignored; 0 measured
1 parent fb90734 commit 68091f7

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/parser.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,13 @@ impl<'a> Parser<'a> {
541541
self.serialization.push_str("file:///");
542542
let scheme_end = "file".len() as u32;
543543
let path_start = "file://".len();
544-
if let Some(base_url) = base_file_url {
545-
let first_segment = base_url.path_segments().unwrap().next().unwrap();
546-
// FIXME: *normalized* drive letter
547-
if is_windows_drive_letter(first_segment) {
548-
self.serialization.push_str(first_segment);
549-
self.serialization.push('/');
544+
if !starts_with_windows_drive_letter_segment(&input_after_first_char) {
545+
if let Some(base_url) = base_file_url {
546+
let first_segment = base_url.path_segments().unwrap().next().unwrap();
547+
if is_normalized_windows_drive_letter(first_segment) {
548+
self.serialization.push_str(first_segment);
549+
self.serialization.push('/');
550+
}
550551
}
551552
}
552553
let remaining = self.parse_path(
@@ -1361,6 +1362,10 @@ pub fn to_u32(i: usize) -> ParseResult<u32> {
13611362
}
13621363
}
13631364

1365+
fn is_normalized_windows_drive_letter(segment: &str) -> bool {
1366+
is_windows_drive_letter(segment) && segment.as_bytes()[1] == b':'
1367+
}
1368+
13641369
/// Wether the scheme is file:, the path has a single segment, and that segment
13651370
/// is a Windows drive letter
13661371
fn is_windows_drive_letter(segment: &str) -> bool {

0 commit comments

Comments
 (0)