From d42094ea724179e339aae447512a3cf9d04d516c Mon Sep 17 00:00:00 2001 From: Laurence Withers Date: Fri, 29 Mar 2019 09:17:15 +0000 Subject: [PATCH] Handler: call path.Clean first Cope with things like /foo//bar by calling path.Clean before searching for path in the map. --- handler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/handler.go b/handler.go index 62a055d..072d61c 100644 --- a/handler.go +++ b/handler.go @@ -4,6 +4,7 @@ import ( "net" "net/http" "os" + "path" "strconv" "strings" "time" @@ -102,7 +103,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - info := h.dir[req.URL.Path] + info := h.dir[path.Clean(req.URL.Path)] if info == nil { http.NotFound(w, req) return