Browse Source

Remove the flag from UnescapeVars

pull/662/head
Francesco Mari 4 years ago
parent
commit
11231c0e93
  1. 8
      mux.go
  2. 2
      mux_test.go

8
mux.go

@ -269,10 +269,10 @@ func (r *Router) SkipClean(value bool) *Router {
// For example, if the router is configured only with UseEncodedPath(), and // For example, if the router is configured only with UseEncodedPath(), and
// "/path/foo%2Fbar/to" matches the path template "/path/{var}/to", your handler // "/path/foo%2Fbar/to" matches the path template "/path/{var}/to", your handler
// will receive the value "foo%2Fbar" for the variable "var". Instead, if the // will receive the value "foo%2Fbar" for the variable "var". Instead, if the
// router is configured with both UseEncodedPath() and UnescapeVars(true), the // router is configured with both UseEncodedPath() and UnescapeVars(), the value
// value for the variable "var" will be "foo/bar". // for the variable "var" will be "foo/bar".
func (r *Router) UnescapeVars(value bool) *Router { func (r *Router) UnescapeVars() *Router {
r.unescapeVars = value r.unescapeVars = true
return r return r
} }

2
mux_test.go

@ -1553,7 +1553,7 @@ func TestUseEncodedPath(t *testing.T) {
}, },
{ {
title: "Router with useEncodedPath, URL with encoded slash does match, variables decoded", title: "Router with useEncodedPath, URL with encoded slash does match, variables decoded",
route: NewRouter().UseEncodedPath().UnescapeVars(true).NewRoute().Path("/v1/{v1}/v2"), route: NewRouter().UseEncodedPath().UnescapeVars().NewRoute().Path("/v1/{v1}/v2"),
request: newRequest("GET", "http://localhost/v1/1%2F2/v2"), request: newRequest("GET", "http://localhost/v1/1%2F2/v2"),
vars: map[string]string{"v1": "1/2"}, vars: map[string]string{"v1": "1/2"},
host: "", host: "",

Loading…
Cancel
Save