From 2f55d28b5cffe7ba43eb9755ea8d54388aa48758 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sun, 26 Jul 2026 20:54:45 +0200 Subject: [PATCH] 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 --- lib/api/api_statics.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/api/api_statics.go b/lib/api/api_statics.go index 861565e1d..789103f5e 100644 --- a/lib/api/api_statics.go +++ b/lib/api/api_statics.go @@ -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"