From 1009fd94d528d74a4a66d92b4d8de7746d4a10ca Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sun, 9 Jul 2023 23:44:47 +0700 Subject: lib/http: fix missing query when handling redirect in HandleFS In 06e6cbdd511c, we redirect request by adding end slash to the path if the requested resource is directory, but somehow we miss adding the original request query. This changes fix this issue. --- lib/http/server.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/http/server.go b/lib/http/server.go index 3bf96049..96a2a902 100644 --- a/lib/http/server.go +++ b/lib/http/server.go @@ -490,7 +490,11 @@ func (srv *Server) HandleFS(res http.ResponseWriter, req *http.Request) { // If request path is a directory and it is not end with // slash, redirect request to location with slash to allow // relative links works inside the HTML content. - http.Redirect(res, req, req.URL.Path+"/", http.StatusFound) + var redirectPath = req.URL.Path + "/" + if len(req.URL.RawQuery) > 0 { + redirectPath += "?" + req.URL.RawQuery + } + http.Redirect(res, req, redirectPath, http.StatusFound) return } -- cgit v1.3