Skip to content

Commit 72d9192

Browse files
committed
fix: adapt seanmonstar#176
1 parent 916b410 commit 72d9192

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,17 +953,18 @@ fn parse_token<'a>(bytes: &mut Bytes<'a>) -> Result<&'a str> {
953953
#[allow(missing_docs)]
954954
// WARNING: Exported for internal benchmarks, not fit for public consumption
955955
pub fn parse_uri<'a>(bytes: &mut Bytes<'a>) -> Result<&'a str> {
956-
// URI must have at least one char
957956
let uri_len = simd::match_uri_vectored(bytes.as_ref());
958-
if uri_len == 0 {
959-
return Err(Error::Token);
960-
}
961957
// SAFETY: these bytes have just been matched here above.
962958
unsafe { bytes.advance(uri_len) };
959+
963960
let uri_slice = bytes.slice();
964961

965962
let space_delim = next!(bytes);
966963
if space_delim == b' ' {
964+
// URI must have at least one char
965+
if uri_len == 0 {
966+
return Err(Error::Token);
967+
}
967968
// SAFETY: all bytes within `uri_slice` must have been `is_token` and therefore also utf-8.
968969
let uri = unsafe { str::from_utf8_unchecked(uri_slice) };
969970
Ok(Status::Complete(uri))

0 commit comments

Comments
 (0)