Skip to content

Commit 55933eb

Browse files
bearcageseanmonstar
authored andcommitted
Fix parse_uri to pass the new tests
1 parent b2b3ce6 commit 55933eb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -955,12 +955,14 @@ fn parse_token<'a>(bytes: &mut Bytes<'a>) -> Result<&'a str> {
955955
pub fn parse_uri<'a>(bytes: &mut Bytes<'a>) -> Result<&'a str> {
956956
let start = bytes.pos();
957957
simd::match_uri_vectored(bytes);
958-
// URI must have at least one char
959-
if bytes.pos() == start {
960-
return Err(Error::Token);
961-
}
958+
let end = bytes.pos();
962959

963960
if next!(bytes) == b' ' {
961+
// URI must have at least one char
962+
if end == start {
963+
return Err(Error::Token);
964+
}
965+
964966
return Ok(Status::Complete(
965967
// SAFETY: all bytes up till `i` must have been `is_token` and therefore also utf-8.
966968
unsafe { str::from_utf8_unchecked(bytes.slice_skip(1)) },

0 commit comments

Comments
 (0)