fix(api): handle empty path in static request (#10837)

The panic would be recovered by the HTTP server, but this is cleaner.

Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
Jakob Borg
2026-07-26 18:54:45 +00:00
committed by GitHub
parent 733f63592f
commit 2f55d28b5c
+1 -5
View File
@@ -74,11 +74,7 @@ func (s *staticsServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func (s *staticsServer) serveAsset(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-cache, must-revalidate")
file := r.URL.Path
if file[0] == '/' {
file = file[1:]
}
file := strings.TrimPrefix(r.URL.Path, "/")
if file == "" {
file = "index.html"