fix: query parameter matching with equal
This commit is contained in:
parent
9cd54baca4
commit
d04903edb2
2 changed files with 9 additions and 1 deletions
|
@ -237,7 +237,7 @@ func headersRegexp(route *mux.Route, headers ...string) error {
|
||||||
func query(route *mux.Route, query ...string) error {
|
func query(route *mux.Route, query ...string) error {
|
||||||
var queries []string
|
var queries []string
|
||||||
for _, elem := range query {
|
for _, elem := range query {
|
||||||
queries = append(queries, strings.Split(elem, "=")...)
|
queries = append(queries, strings.SplitN(elem, "=", 2)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
route.Queries(queries...)
|
route.Queries(queries...)
|
||||||
|
|
|
@ -252,6 +252,14 @@ func Test_addRoute(t *testing.T) {
|
||||||
"http://localhost/foo?bar=baz": http.StatusNotFound,
|
"http://localhost/foo?bar=baz": http.StatusNotFound,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "Query with multiple equals",
|
||||||
|
rule: "Query(`foo=b=ar`)",
|
||||||
|
expected: map[string]int{
|
||||||
|
"http://localhost/foo?foo=b=ar": http.StatusOK,
|
||||||
|
"http://localhost/foo?foo=bar": http.StatusNotFound,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
desc: "Rule with simple path",
|
desc: "Rule with simple path",
|
||||||
rule: `Path("/a")`,
|
rule: `Path("/a")`,
|
||||||
|
|
Loading…
Reference in a new issue