From 75140f716d1c0236c7ce2a3ed7a3bef1ed21a98b Mon Sep 17 00:00:00 2001 From: bakonpancakz Date: Sat, 18 Jul 2026 04:03:57 -0700 Subject: [PATCH] bug: trailing slash issue manually writing a dir caused path traversal issues in the html so we force a trailing slash to prevent this --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index 7b9cf38..7e5ebda 100644 --- a/main.go +++ b/main.go @@ -152,6 +152,13 @@ func main() { return } + // Append trailing slash to directories so rendered HTML has proper paths + if filestat.IsDir() && !strings.HasSuffix(r.URL.Path, "/") { + r.URL.Path += "/" + http.Redirect(w, r, r.URL.String(), http.StatusMovedPermanently) + return + } + // Use Browser Cache (if possible) modtime := filestat.ModTime().UTC() modhash := fmt.Sprint(modtime.Unix())