From d10d5466f2db2758bb616f627775692d2f69fe8a Mon Sep 17 00:00:00 2001 From: Philip Schlump Date: Thu, 14 Nov 2013 19:27:38 -0700 Subject: [PATCH] Fixed problem with droping query string. --- mux.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mux.go b/mux.go index ddc1acc..ca51a01 100644 --- a/mux.go +++ b/mux.go @@ -67,6 +67,14 @@ func (r *Router) Match(req *http.Request, match *RouteMatch) bool { func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { // Clean path to canonical form and redirect. if p := cleanPath(req.URL.Path); p != req.URL.Path { + + // Added 3 lines (Philip Schlump) - It was droping the query string and #whatever from query. + // This matches with fix in go 1.2 r.c. 4 for same problem. Go Issue: + // http://code.google.com/p/go/issues/detail?id=5252 + url := *req.URL + url.Path = p + p = url.String() + w.Header().Set("Location", p) w.WriteHeader(http.StatusMovedPermanently) return