From e7360abac05879a9482dbff1bb08c8a5df951750 Mon Sep 17 00:00:00 2001 From: wesemann Date: Fri, 30 Aug 2024 10:30:24 +0200 Subject: [PATCH] Only add base_path if req_pandq does not contain it (#684) * avoids adding it twice * fixes issue with pagination not working due to base path added twice Co-authored-by: Markus Wesemann --- src/service/middleware/base_uri.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/service/middleware/base_uri.rs b/src/service/middleware/base_uri.rs index a4aa9324..8d86753e 100644 --- a/src/service/middleware/base_uri.rs +++ b/src/service/middleware/base_uri.rs @@ -89,7 +89,11 @@ fn overwrite_base_uri(base_uri: &http::Uri, current_uri: Uri) -> http::Uri { // Remove any trailing slashes and join. // `PathAndQuery` always starts with a slash. let base_path = pandq.path().trim_end_matches('/'); - builder.path_and_query(format!("{base_path}{req_pandq}")) + if !req_pandq.as_str().starts_with(base_path) { + builder.path_and_query(format!("{base_path}{req_pandq}")) + } else { + builder.path_and_query(req_pandq.as_str()) + } } else { builder.path_and_query(pandq.as_str()) };