adding test and updating condition

This commit is contained in:
Bay Dodd
2015-07-16 12:45:51 +01:00
parent 2b32409792
commit 19f0a91c4e
2 changed files with 14 additions and 2 deletions

View File

@@ -89,8 +89,11 @@ func newRouteRegexp(tpl string, matchHost, matchPrefix, matchQuery, strictSlash
if strictSlash {
pattern.WriteString("[/]?")
}
if matchQuery && len(idxs) == 0 {
pattern.WriteString(defaultPattern)
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('$')