diff options
author | Alan Pearce | 2024-04-24 11:47:42 +0200 |
---|---|---|
committer | Alan Pearce | 2024-04-24 11:47:42 +0200 |
commit | a20707fc8982d76e60c2e6cd058baa32334c7a4f (patch) | |
tree | 3e781e2cd6cff90643d07649fa8b66c729fa4fc1 /cmd | |
parent | d2a85e99c50b841ef93e59b732c6330c636b391f (diff) | |
download | website-a20707fc8982d76e60c2e6cd058baa32334c7a4f.tar.lz website-a20707fc8982d76e60c2e6cd058baa32334c7a4f.tar.zst website-a20707fc8982d76e60c2e6cd058baa32334c7a4f.zip |
fix path canonicalisation
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/server/server.go | 3 |
1 files changed, 2 insertions, 1 deletions
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 { |