Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 16:45 UTC
fileserver: Use safe redirects in file browser
Matthew Holt committed
Jul 7, 2022 at 14:10 UTC
c0f76e9ed482b0abde0c3d8f5e26e9f015418ca3
1 file changed
+1
-3
modules/caddyhttp/fileserver/browse.go
+1
-3
@@ -67,9 +67,7 @@ func (fsrv *FileServer) serveBrowse(root, dirPath string, w http.ResponseWriter,
67
if r.URL.Path == "" || path.Base(origReq.URL.Path) == path.Base(r.URL.Path) {
68
if !strings.HasSuffix(origReq.URL.Path, "/") {
69
fsrv.logger.Debug("redirecting to trailing slash to preserve hrefs", zap.String("request_path", r.URL.Path))
70
- origReq.URL.Path += "/"
71
- http.Redirect(w, r, origReq.URL.String(), http.StatusMovedPermanently)
72
- return nil
70
+ return redirect(w, r, origReq.URL.Path+"/")
71
}
72
}
73