diff options
-rw-r--r-- | modules/caddyhttp/fileserver/staticfiles.go | 7 | ||||
-rw-r--r-- | modules/caddyhttp/fileserver/staticfiles_test.go | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go index bb9fc4357..0777ca1d0 100644 --- a/modules/caddyhttp/fileserver/staticfiles.go +++ b/modules/caddyhttp/fileserver/staticfiles.go @@ -519,6 +519,13 @@ func fileHidden(filename string, show []string, hide []string) bool { // cache the components of the input filename var components []string + // if the filename is the root of the fileserver, then + // it should always be shown, because otherwise the + // index would always be hidden + if filename == separator { + goto shown + } + for _, s := range show { if !strings.Contains(s, separator) { // if there is no separator in s, then we assume the user diff --git a/modules/caddyhttp/fileserver/staticfiles_test.go b/modules/caddyhttp/fileserver/staticfiles_test.go index bd0370518..1f9232206 100644 --- a/modules/caddyhttp/fileserver/staticfiles_test.go +++ b/modules/caddyhttp/fileserver/staticfiles_test.go @@ -155,6 +155,12 @@ func TestFileHidden(t *testing.T) { expect: true, }, { + inputShow: []string{"/foo"}, + inputHide: nil, + inputPath: "/", + expect: false, + }, + { inputShow: []string{"*.txt"}, inputHide: []string{"/foo"}, inputPath: "/foo/bar.txt", |