Skip to content

Commit

Permalink
Fixed problem with droping query string.
Browse files Browse the repository at this point in the history
  • Loading branch information
pschlump committed Nov 15, 2013
1 parent 42cbcc5 commit d10d546
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d10d546

Please sign in to comment.