api: use split terminator...
...to support trailing slash in url
This commit is contained in:
parent
047856ddf3
commit
2f5a116dce
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue