diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2021-06-14 09:03:56 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2021-06-14 09:04:30 -0600 |
commit | 8848df9c5d372a559d01512b7a4ef00e38867b55 (patch) | |
tree | 6c3d33b403b7f015204fea708582d331d7e51d01 /modules/caddyhttp/fileserver/browse.go | |
parent | 89aa3a5ef3e0da58d8a165ffe4c073fda52994db (diff) |
Revert "fileserver: Redirect within the original URL (#4179)"
This reverts commit f9b54454a19e2b070159ce8d2af76d819658244e.
/cc @diamondburned (see #4205)
Diffstat (limited to 'modules/caddyhttp/fileserver/browse.go')
-rw-r--r-- | modules/caddyhttp/fileserver/browse.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/modules/caddyhttp/fileserver/browse.go b/modules/caddyhttp/fileserver/browse.go index fa6da68..fc8bddb 100644 --- a/modules/caddyhttp/fileserver/browse.go +++ b/modules/caddyhttp/fileserver/browse.go @@ -47,11 +47,10 @@ func (fsrv *FileServer) serveBrowse(root, dirPath string, w http.ResponseWriter, // URL doesn't end in a trailing slash because hrefs like // "/b/c" on a path like "/a" end up going to "/b/c" instead // of "/a/b/c" - so we have to redirect in this case - 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)) - oldReq.URL.Path += "/" - http.Redirect(w, r, oldReq.URL.String(), http.StatusMovedPermanently) + if !strings.HasSuffix(r.URL.Path, "/") { + fsrv.logger.Debug("redirecting to trailing slash to preserve hrefs", zap.String("request_path", r.URL.Path)) + r.URL.Path += "/" + http.Redirect(w, r, r.URL.String(), http.StatusMovedPermanently) return nil } |