@ -597,6 +597,15 @@ func TestQueries(t *testing.T) {
path: "",
shouldMatch: true,
},
{
title: "Queries route with overlapping value, should not match",
route: new(Route).Queries("foo", "bar"),
request: newRequest("GET", "http://localhost?foo=barfoo"),
vars: map[string]string{},
host: "",
shouldMatch: false,
}
for _, test := range tests {
@ -89,9 +89,12 @@ func newRouteRegexp(tpl string, matchHost, matchPrefix, matchQuery, strictSlash
if strictSlash {
pattern.WriteString("[/]?")
if matchQuery && len(idxs) == 0 {
if matchQuery {
// Add the default pattern if the query value is empty
if queryVal := strings.SplitN(template, "=", 2)[1]; queryVal == "" {
pattern.WriteString(defaultPattern)
if !matchPrefix {
pattern.WriteByte('$')