From 73078bf370f5f73a0375b441388f8d491efac550 Mon Sep 17 00:00:00 2001 From: Trezy Date: Fri, 8 May 2026 13:06:40 -0500 Subject: [PATCH] fix: prevent false match rewrites when a base path is in use Signed-off-by: Trezy --- src/server.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server.rs b/src/server.rs index 31fc30c..26bc268 100644 --- a/src/server.rs +++ b/src/server.rs @@ -149,7 +149,9 @@ pub fn router(state: AppState) -> Router { && let Some(loc) = response.headers().get(header::LOCATION) && let Ok(loc_str) = loc.to_str() && loc_str.starts_with('/') - && !loc_str.starts_with(&bp) + && !(loc_str.starts_with(&bp) + && (loc_str.len() == bp.len() + || loc_str.as_bytes().get(bp.len()) == Some(&b'/'))) && let Ok(new_loc) = format!("{}{}", bp, loc_str).parse() { response.headers_mut().insert(header::LOCATION, new_loc); -- 2.51.2