Skip to content

Commit b09e48e

Browse files
committed
fix: empty string handling in NgxStr::from_ngx_str
Fixes #150
1 parent a1ffd81 commit b09e48e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/core/string.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use core::slice;
21
use core::str::{self, Utf8Error};
32

43
#[cfg(all(not(feature = "std"), feature = "alloc"))]
@@ -39,7 +38,7 @@ impl NgxStr {
3938
/// to range of bytes of at least `len` bytes, whose content remains valid and doesn't
4039
/// change for the lifetime of the returned `NgxStr`.
4140
pub unsafe fn from_ngx_str<'a>(str: ngx_str_t) -> &'a NgxStr {
42-
slice::from_raw_parts(str.data, str.len).into()
41+
str.as_bytes().into()
4342
}
4443

4544
/// Access the [`NgxStr`] as a byte slice.

0 commit comments

Comments
 (0)