Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions url/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,14 @@ impl<'a> Parser<'a> {
}

pub fn parse_scheme<'i>(&mut self, mut input: Input<'i>) -> Result<Input<'i>, ()> {
if input.is_empty() || !input.starts_with(ascii_alpha) {
if !input.starts_with(ascii_alpha) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment that starts_with will also fail for empty strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment and unit test.

return Err(());
}
debug_assert!(self.serialization.is_empty());
while let Some(c) = input.next() {
match c {
'a'..='z' | 'A'..='Z' | '0'..='9' | '+' | '-' | '.' => {
self.serialization.push(c.to_ascii_lowercase())
}
'a'..='z' | '0'..='9' | '+' | '-' | '.' => self.serialization.push(c),
'A'..='Z' => self.serialization.push(c.to_ascii_lowercase()),
':' => return Ok(input),
_ => {
self.serialization.clear();
Expand Down
Loading