diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2026-09-06 01:36:45 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2026-09-06 01:37:03 -0700 |
| commit | 86ed7a3955c27d1c0826b9c00a5f79d6547afb37 (patch) | |
| tree | 653d8e0d33b43ecf1fdf2983e359625ea23b2ea3 | |
| parent | Use ServeFileFS for static files (diff) | |
| download | roseh.moe-86ed7a3955c27d1c0826b9c00a5f79d6547afb37.tar.zst | |
Use path.Clean so that directories can be routed
| -rw-r--r-- | roseh.moe.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/roseh.moe.go b/roseh.moe.go index 32bcb6c..d28b1a5 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -28,6 +28,7 @@ import ( "net/http/httputil" "net/url" "os" + "path" "path/filepath" "slices" "strconv" @@ -264,7 +265,7 @@ func serveStaticFile(w http.ResponseWriter, r *http.Request, path string) { } func static(w http.ResponseWriter, r *http.Request) { - serveStaticFile(w, r, strings.TrimPrefix(r.URL.Path, "/")) + serveStaticFile(w, r, path.Clean(strings.TrimPrefix(r.URL.Path, "/"))) } func favicon(w http.ResponseWriter, r *http.Request) { |
