Skip to content

Commit

Permalink
Fix parse_uri to pass the new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bearcage authored and seanmonstar committed Jun 17, 2024
1 parent b2b3ce6 commit 55933eb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,12 +955,14 @@ fn parse_token<'a>(bytes: &mut Bytes<'a>) -> Result<&'a str> {
pub fn parse_uri<'a>(bytes: &mut Bytes<'a>) -> Result<&'a str> {
let start = bytes.pos();
simd::match_uri_vectored(bytes);
// URI must have at least one char
if bytes.pos() == start {
return Err(Error::Token);
}
let end = bytes.pos();

if next!(bytes) == b' ' {
// URI must have at least one char
if end == start {
return Err(Error::Token);
}

return Ok(Status::Complete(
// SAFETY: all bytes up till `i` must have been `is_token` and therefore also utf-8.
unsafe { str::from_utf8_unchecked(bytes.slice_skip(1)) },
Expand Down

0 comments on commit 55933eb

Please sign in to comment.