From af984b71e99a59c8f1a82beab277b8e67cf8ed7d Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Thu, 27 Sep 2018 03:34:45 -0400 Subject: [PATCH] ensure subpath redirect preserves query string correctly (#9444) The previous code appended a `/` to the end of the URL, breaking if a query string was present. --- web/static.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/static.go b/web/static.go index 64d326e243ebf..800bd2b72cc82 100644 --- a/web/static.go +++ b/web/static.go @@ -45,7 +45,8 @@ func (w *Web) InitStatic() { // trailing slash. We don't want to use StrictSlash on the w.MainRouter and affect // all routes, just /subpath -> /subpath/. w.MainRouter.HandleFunc("", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, r.URL.String()+"/", http.StatusFound) + r.URL.Path += "/" + http.Redirect(w, r, r.URL.String(), http.StatusFound) })) } }