From 28488a75c2572cabe249ee3d2c488a403308d9e0 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 30 Dec 2024 15:31:48 +0400 Subject: [PATCH] Added a fool proof to remove a trailing slash of a base directoryPath. --- cmd/dwelling-files/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/dwelling-files/main.go b/cmd/dwelling-files/main.go index 8cde8f5..e219c54 100644 --- a/cmd/dwelling-files/main.go +++ b/cmd/dwelling-files/main.go @@ -43,6 +43,10 @@ func main() { r.Handler(http.MethodGet, "/*filepath", Index) r.ServeStatic("/assets/*filepath", web.Assets()) + if (*directoryPath)[len(*directoryPath)-1] == '/' { + *directoryPath = (*directoryPath)[:len(*directoryPath)-1] + } + var fileServer http.Handler if *enableFileHandler { fileServer = http.FileServer(http.Dir(*directoryPath))