Skip to content

Commit

Permalink
url: Don't parse empty hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Jul 26, 2024
1 parent fce6b10 commit 7747ceb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/url/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ impl<'a> Parser<'a> {

if c == ':' && !inside_brackets {
let host_buffer = &self.input.source()[host_start..self.input.position() - 1];

if host_buffer.is_empty() {
return Err(Error::MissingHost);
}

let host = host::parse_with_special(host_buffer, !is_special_url)?;
let host_serialization: ascii::String =
ascii::String::try_from(format!("{host}")).expect("is ascii");
Expand Down

0 comments on commit 7747ceb

Please sign in to comment.