summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorJesse Hallam <jesse.hallam@gmail.com>2018-09-27 03:34:45 -0400
committerCarlos Tadeu Panato Junior <ctadeu@gmail.com>2018-09-27 09:34:45 +0200
commitaf984b71e99a59c8f1a82beab277b8e67cf8ed7d (patch)
tree29dbfa6728cce360fc721df148ccff489d95f179 /web
parent6a4d21d05654bdde2e0a48c1d1bddc490b6d296e (diff)
downloadchat-af984b71e99a59c8f1a82beab277b8e67cf8ed7d.tar.gz
chat-af984b71e99a59c8f1a82beab277b8e67cf8ed7d.tar.bz2
chat-af984b71e99a59c8f1a82beab277b8e67cf8ed7d.zip
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.
Diffstat (limited to 'web')
-rw-r--r--web/static.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/web/static.go b/web/static.go
index 64d326e24..800bd2b72 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)
}))
}
}