Skip to content

Commit 6f78868

Browse files
committed
Start with windows drive letter is also valid if its length is 2.
1 parent 99228e5 commit 6f78868

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/parser.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -1539,8 +1539,20 @@ fn starts_with_windows_drive_letter(s: &str) -> bool {
15391539
ascii_alpha(s.as_bytes()[0] as char) && matches!(s.as_bytes()[1], b':' | b'|')
15401540
}
15411541

1542+
/// https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
15421543
fn starts_with_windows_drive_letter_segment(input: &Input) -> bool {
15431544
let mut input = input.clone();
1544-
matches!((input.next(), input.next(), input.next()), (Some(a), Some(b), Some(c))
1545-
if ascii_alpha(a) && matches!(b, ':' | '|') && matches!(c, '/' | '\\' | '?' | '#'))
1545+
match (input.next(), input.next(), input.next()) {
1546+
// its first two code points are a Windows drive letter
1547+
// its third code point is U+002F (/), U+005C (\), U+003F (?), or U+0023 (#).
1548+
(Some(a), Some(b), Some(c))
1549+
if ascii_alpha(a) && matches!(b, ':' | '|') && matches!(c, '/' | '\\' | '?' | '#') =>
1550+
{
1551+
true
1552+
}
1553+
// its first two code points are a Windows drive letter
1554+
// its length is 2
1555+
(Some(a), Some(b), None) if ascii_alpha(a) && matches!(b, ':' | '|') => true,
1556+
_ => false,
1557+
}
15461558
}

0 commit comments

Comments
 (0)