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.
This commit is contained in:
Jesse Hallam
2018-09-27 03:34:45 -04:00
committed by Carlos Tadeu Panato Junior
parent 6a4d21d056
commit af984b71e9

View File

@@ -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)
}))
}
}