UI: Trim trailing slashes to avoid redirects (#4668)

This commit is contained in:
Brian Kassouf 2018-05-31 12:52:43 -07:00 committed by GitHub
parent 2528a261bf
commit 80580b82f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -273,6 +273,11 @@ func handleUIHeaders(core *vault.Core, h http.Handler) http.Handler {
func handleUI(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
// The fileserver handler strips trailing slashes and does a redirect.
// We don't want the redirect to happen so we preemptively trim the slash
// here.
req.URL.Path = strings.TrimSuffix(req.URL.Path, "/")
h.ServeHTTP(w, req)
return
})