api: use split terminator...

...to support trailing slash in url
This commit is contained in:
Dmitriy Pleshevskiy 2022-05-24 22:23:01 +03:00
parent 047856ddf3
commit 2f5a116dce
1 changed files with 3 additions and 3 deletions

View File

@ -31,7 +31,7 @@ impl Url<'_> {
}
fn extract_path_segments(path: &str) -> Vec<&str> {
path.split('/').skip(1).collect()
path.split_terminator('/').skip(1).collect()
}
fn extract_query_params(query: Option<&str>) -> Vec<QueryParam> {
@ -64,11 +64,11 @@ mod tests {
}
#[test]
fn should_extract_tralling_slash_as_empty_segment() {
fn should_not_extract_tralling_slash_as_empty_segment() {
let path = "/hello/world/";
let segments = extract_path_segments(path);
assert_eq!(segments, ["hello", "world", ""]);
assert_eq!(segments, ["hello", "world"]);
}
#[test]