Skip to content

Commit 0550fb7

Browse files
committed
Start with windows drive letter is also valid if its length is 2.
1 parent 0b07c82 commit 0550fb7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/parser.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,8 +1557,20 @@ fn starts_with_windows_drive_letter(s: &str) -> bool {
15571557
ascii_alpha(s.as_bytes()[0] as char) && matches!(s.as_bytes()[1], b':' | b'|')
15581558
}
15591559

1560+
/// https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
15601561
fn starts_with_windows_drive_letter_segment(input: &Input) -> bool {
15611562
let mut input = input.clone();
1562-
matches!((input.next(), input.next(), input.next()), (Some(a), Some(b), Some(c))
1563-
if ascii_alpha(a) && matches!(b, ':' | '|') && matches!(c, '/' | '\\' | '?' | '#'))
1563+
match (input.next(), input.next(), input.next()) {
1564+
// its first two code points are a Windows drive letter
1565+
// its third code point is U+002F (/), U+005C (\), U+003F (?), or U+0023 (#).
1566+
(Some(a), Some(b), Some(c))
1567+
if ascii_alpha(a) && matches!(b, ':' | '|') && matches!(c, '/' | '\\' | '?' | '#') =>
1568+
{
1569+
true
1570+
}
1571+
// its first two code points are a Windows drive letter
1572+
// its length is 2
1573+
(Some(a), Some(b), None) if ascii_alpha(a) && matches!(b, ':' | '|') => true,
1574+
_ => false,
1575+
}
15641576
}

0 commit comments

Comments
 (0)