Serve the index page for an empty URL path instead of panicking (closes #149)
check / check (push) Canceled after 0s

setupSPA took the file name from request.URL.Path[1:], which panics
when the path is empty, as it is for an absolute-form request line
with no path ("GET http://host HTTP/1.1"). It now trims a leading "/"
instead; an empty name fails to read, so the request gets the index
page, as "/" already does.

The new test in internal/server sends such a request and expects 200
and the index page. export_test.go gives it a Server whose router has
only the web client route.

Model: opus-5-5
This commit is contained in:
2026-10-20 18:59:15 +00:00
parent e3d01454b3
commit fd3c4f42e7
3 changed files with 57 additions and 1 deletions
+12
View File
@@ -0,0 +1,12 @@
package server
import "github.com/go-chi/chi/v5"
// NewTestSPAServer creates a Server whose router serves only
// the embedded web client.
func NewTestSPAServer() *Server {
srv := &Server{router: chi.NewRouter()}
srv.setupSPA()
return srv
}