From 404f88c099a576f7ce656d727645d6a930e09b37 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 13 Aug 2023 03:18:17 +0400 Subject: [PATCH] Fix for double slashes. --- internal/http/handlers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/http/handlers.go b/internal/http/handlers.go index 6bc9e67..c636971 100644 --- a/internal/http/handlers.go +++ b/internal/http/handlers.go @@ -6,6 +6,7 @@ import ( "dwelling-files/web" "log" "net/http" + "strings" "git.arav.su/Arav/httpr" ) @@ -30,7 +31,10 @@ func New(directoryPath *string, noFileHandling bool) *FilesHandlers { } func (h *FilesHandlers) Index(w http.ResponseWriter, r *http.Request) { - path := "/" + httpr.Param(r, "filepath") + "/" + path := "/" + httpr.Param(r, "filepath") + if !strings.HasSuffix(path, "/") { + path += "/" + } currentPath := files.CurrentPath(path)