From 2f5a116dceb32841e18e576df0c4e14a63763a35 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Tue, 24 May 2022 22:23:01 +0300 Subject: [PATCH] api: use split terminator... ...to support trailing slash in url --- api/src/rest/types.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/rest/types.rs b/api/src/rest/types.rs index 1978d27..4c56c81 100644 --- a/api/src/rest/types.rs +++ b/api/src/rest/types.rs @@ -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 { @@ -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]