Skip to content

Commit

Permalink
ensure subpath redirect preserves query string correctly (#9444)
Browse files Browse the repository at this point in the history
The previous code appended a `/` to the end of the URL, breaking if a
query string was present.
  • Loading branch information
lieut-data authored and cpanato committed Sep 27, 2018
1 parent 6a4d21d commit af984b7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion web/static.go
Expand Up @@ -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)
}))
}
}
Expand Down

0 comments on commit af984b7

Please sign in to comment.