From 8463eed5bab52530d3d5a144d760df2a6bb1481b Mon Sep 17 00:00:00 2001 From: phanirithvij Date: Thu, 20 Aug 2026 14:20:21 +0200 Subject: [PATCH] Retain query params for automatic redirects to `.../`. Co-authored-by: phanirithvij Reviewed-on: https://codeberg.org/git-pages/git-pages/pulls/253 Reviewed-by: Catherine --- src/pages.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages.go b/src/pages.go index 6e4d3df..7488b08 100644 --- a/src/pages.go +++ b/src/pages.go @@ -164,7 +164,9 @@ func getPage(w http.ResponseWriter, r *http.Request) error { ) if err == nil { if !hasProjectSlash { - writeRedirect(w, http.StatusFound, r.URL.Path+"/") + newURL := *r.URL + newURL.Path += "/" + writeRedirect(w, http.StatusFound, newURL.String()) return nil } sitePath, manifest, metadata = projectPath, projectManifest, projectMetadata @@ -364,8 +366,9 @@ func getPage(w http.ResponseWriter, r *http.Request) error { } else { // redirect from `dir` to `dir/`, otherwise when `dir/index.html` is served, // links in it will have the wrong base URL - newPath := r.URL.Path + "/" - writeRedirect(w, http.StatusFound, newPath) + newURL := *r.URL + newURL.Path += "/" + writeRedirect(w, http.StatusFound, newURL.String()) return nil } } else if entry.GetType() == Type_Symlink {