Y.Horie
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
25 additions and
0 deletions
-
caddytest/integration/caddyfile_test.go
-
caddytest/integration/testdata/index.localhost.html
-
modules/caddyhttp/fileserver/staticfiles.go
|
|
@ -101,3 +101,27 @@ func TestReadCookie(t *testing.T) { |
|
|
|
// act and assert
|
|
|
|
tester.AssertGetResponse("http://localhost:9080/cookie.html", 200, "<h2>Cookie.ClientName caddytest</h2>") |
|
|
|
} |
|
|
|
|
|
|
|
func TestReplIndex(t *testing.T) { |
|
|
|
|
|
|
|
tester := caddytest.NewTester(t) |
|
|
|
tester.InitServer(` |
|
|
|
{ |
|
|
|
http_port 9080 |
|
|
|
https_port 9443 |
|
|
|
} |
|
|
|
|
|
|
|
localhost:9080 { |
|
|
|
templates { |
|
|
|
root testdata |
|
|
|
} |
|
|
|
file_server { |
|
|
|
root testdata |
|
|
|
index "index.{host}.html" |
|
|
|
} |
|
|
|
} |
|
|
|
`, "caddyfile") |
|
|
|
|
|
|
|
// act and assert
|
|
|
|
tester.AssertGetResponse("http://localhost:9080/", 200, "") |
|
|
|
} |
|
|
|
|
|
@ -200,6 +200,7 @@ func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request, next c |
|
|
|
var implicitIndexFile bool |
|
|
|
if info.IsDir() && len(fsrv.IndexNames) > 0 { |
|
|
|
for _, indexPage := range fsrv.IndexNames { |
|
|
|
indexPage := repl.ReplaceAll(indexPage, "") |
|
|
|
indexPath := caddyhttp.SanitizedPathJoin(filename, indexPage) |
|
|
|
if fileHidden(indexPath, filesToHide) { |
|
|
|
// pretend this file doesn't exist
|
|
|
|