summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/fileserver
diff options
context:
space:
mode:
authoresell <esell@users.noreply.github.com>2023-03-03 14:45:17 -0700
committerGitHub <noreply@github.com>2023-03-03 14:45:17 -0700
commit94d41a9d86d6ca2d2d001183a62d762ee045094f (patch)
treecc20f661152b4a59d638777ec42bf3f6cd268ef8 /modules/caddyhttp/fileserver
parent99d47050e97a8ccac2aad3bda46be46d4fec85ed (diff)
fileserver: Remove trailing slash on fs filenames (#5417)
Diffstat (limited to 'modules/caddyhttp/fileserver')
-rw-r--r--modules/caddyhttp/fileserver/staticfiles.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go
index c0fde66..0459b3a 100644
--- a/modules/caddyhttp/fileserver/staticfiles.go
+++ b/modules/caddyhttp/fileserver/staticfiles.go
@@ -250,7 +250,8 @@ func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request, next c
root := repl.ReplaceAll(fsrv.Root, ".")
- filename := caddyhttp.SanitizedPathJoin(root, r.URL.Path)
+ // remove any trailing `/` as it breaks fs.ValidPath() in the stdlib
+ filename := strings.TrimSuffix(caddyhttp.SanitizedPathJoin(root, r.URL.Path), "/")
fsrv.logger.Debug("sanitized path join",
zap.String("site_root", root),