summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/fileserver
diff options
context:
space:
mode:
authordiamondburned <datutbrus@gmail.com>2021-06-07 16:33:54 -0700
committerGitHub <noreply@github.com>2021-06-07 17:33:54 -0600
commit76913b19ff053bc5b0848ce4d0bbf73698f30d93 (patch)
tree0ae0cf2c0532b83df78c20a73ac4244590a76907 /modules/caddyhttp/fileserver
parent4c2da188419cf087049a6a3d4d08a859ac94c397 (diff)
fileserver: Fix browse not redirecting query parameters (#4196)
This commit is a follow up to PR #4179 that introduced a bug where browse redirections to the right URL would not preserve query parameters.
Diffstat (limited to 'modules/caddyhttp/fileserver')
-rw-r--r--modules/caddyhttp/fileserver/browse.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/caddyhttp/fileserver/browse.go b/modules/caddyhttp/fileserver/browse.go
index 444a656..fa6da68 100644
--- a/modules/caddyhttp/fileserver/browse.go
+++ b/modules/caddyhttp/fileserver/browse.go
@@ -50,7 +50,8 @@ func (fsrv *FileServer) serveBrowse(root, dirPath string, w http.ResponseWriter,
oldReq := r.Context().Value(caddyhttp.OriginalRequestCtxKey).(http.Request)
if !strings.HasSuffix(oldReq.URL.Path, "/") {
fsrv.logger.Debug("redirecting to trailing slash to preserve hrefs", zap.String("request_path", oldReq.URL.Path))
- http.Redirect(w, r, oldReq.URL.Path+"/", http.StatusMovedPermanently)
+ oldReq.URL.Path += "/"
+ http.Redirect(w, r, oldReq.URL.String(), http.StatusMovedPermanently)
return nil
}