From df5fb001e80bd58ffc6b7425623ff2f17079149b Mon Sep 17 00:00:00 2001 From: Jose Quintana <1700322+joseluisq@users.noreply.github.com> Date: Sun, 11 Jan 2026 22:38:37 +0100 Subject: [PATCH] fix: custom header is not applied when redirect-trailing-slash is disabled (#613) It fixes an issue where custom headers were not applied for directory requests when the `redirect-trailing-slash` was disabled. --- src/custom_headers.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/custom_headers.rs b/src/custom_headers.rs index 45015ad4..29bdb059 100644 --- a/src/custom_headers.rs +++ b/src/custom_headers.rs @@ -24,21 +24,23 @@ pub(crate) fn post_process( advanced.headers.as_deref(), &mut resp, file_path, + opts.redirect_trailing_slash, ) } Ok(resp) } /// Append custom HTTP headers to current response. -pub fn append_headers( +fn append_headers( uri_path: &str, headers_opts: Option<&[Headers]>, resp: &mut Response, file_path: Option<&PathBuf>, + redirect_trailing_slash: bool, ) { if let Some(headers_vec) = headers_opts { let uri_path_auto_index = file_path - .filter(|_| uri_path.ends_with('/')) + .filter(|_| uri_path.ends_with('/') || !redirect_trailing_slash) .and_then(|p| p.file_name()) .and_then(OsStr::to_str) .map(|name| match uri_path {