@marcel91200 / caddy Mirror · read-only / commits / 76913b19
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

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.

diamondburned committed Jun 7, 2021 at 16:33 UTC 76913b19ff053bc5b0848ce4d0bbf73698f30d93
1 file changed +2 -1
modules/caddyhttp/fileserver/browse.go
+2 -1
@@ -50,7 +50,8 @@ func (fsrv *FileServer) serveBrowse(root, dirPath string, w http.ResponseWriter,
50 oldReq := r.Context().Value(caddyhttp.OriginalRequestCtxKey).(http.Request)
51 if !strings.HasSuffix(oldReq.URL.Path, "/") {
52 fsrv.logger.Debug("redirecting to trailing slash to preserve hrefs", zap.String("request_path", oldReq.URL.Path))
53 - http.Redirect(w, r, oldReq.URL.Path+"/", http.StatusMovedPermanently)
53 + oldReq.URL.Path += "/"
54 + http.Redirect(w, r, oldReq.URL.String(), http.StatusMovedPermanently)
55 return nil
56 }
57