From a20707fc8982d76e60c2e6cd058baa32334c7a4f Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Wed, 24 Apr 2024 11:47:42 +0200 Subject: fix path canonicalisation --- cmd/server/server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/server/server.go b/cmd/server/server.go index 39feb86..9c9911a 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -101,12 +101,13 @@ type HTTPError struct { } func canonicalisePath(path string) (cPath string, differs bool) { + cPath = path if strings.HasSuffix(path, "/index.html") { cPath, differs = strings.CutSuffix(path, "index.html") } else if !strings.HasSuffix(path, "/") && files[path+"/"] != (File{}) { cPath, differs = path+"/", true } - return path, differs + return cPath, differs } func serveFile(w http.ResponseWriter, r *http.Request) *HTTPError { -- cgit 1.4.1