summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/fileserver/matcher.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/fileserver/matcher.go')
-rw-r--r--modules/caddyhttp/fileserver/matcher.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/modules/caddyhttp/fileserver/matcher.go b/modules/caddyhttp/fileserver/matcher.go
index 44ef9ed..064398c 100644
--- a/modules/caddyhttp/fileserver/matcher.go
+++ b/modules/caddyhttp/fileserver/matcher.go
@@ -139,6 +139,11 @@ func (m *MatchFile) Provision(_ caddy.Context) error {
if m.Root == "" {
m.Root = "{http.vars.root}"
}
+ // if list of files to try was omitted entirely, assume URL path
+ // (use placeholder instead of r.URL.Path; see issue #4146)
+ if m.TryFiles == nil {
+ m.TryFiles = []string{"{http.request.uri.path}"}
+ }
return nil
}
@@ -174,13 +179,6 @@ func (m MatchFile) selectFile(r *http.Request) (matched bool) {
root := repl.ReplaceAll(m.Root, ".")
- // if list of files to try was omitted entirely,
- // assume URL path
- if m.TryFiles == nil {
- // m is not a pointer, so this is safe
- m.TryFiles = []string{r.URL.Path}
- }
-
// common preparation of the file into parts
prepareFilePath := func(file string) (suffix, fullpath, remainder string) {
suffix, remainder = m.firstSplit(path.Clean(repl.ReplaceAll(file, "")))