Browse Source
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.
master
diamondburned
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
2 additions and
1 deletions
-
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) |
|
|
oldReq := r.Context().Value(caddyhttp.OriginalRequestCtxKey).(http.Request) |
|
|
if !strings.HasSuffix(oldReq.URL.Path, "/") { |
|
|
if !strings.HasSuffix(oldReq.URL.Path, "/") { |
|
|
fsrv.logger.Debug("redirecting to trailing slash to preserve hrefs", zap.String("request_path", 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 |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|