|
|
|
@ -34,7 +34,7 @@ func newRouteRegexp(tpl string, matchHost, matchPrefix, matchQuery, strictSlash |
|
|
|
// Now let's parse it.
|
|
|
|
// Now let's parse it.
|
|
|
|
defaultPattern := "[^/]+" |
|
|
|
defaultPattern := "[^/]+" |
|
|
|
if matchQuery { |
|
|
|
if matchQuery { |
|
|
|
defaultPattern = "[^?]+" |
|
|
|
defaultPattern = "[^?&]+" |
|
|
|
matchPrefix, strictSlash = true, false |
|
|
|
matchPrefix, strictSlash = true, false |
|
|
|
} else if matchHost { |
|
|
|
} else if matchHost { |
|
|
|
defaultPattern = "[^.]+" |
|
|
|
defaultPattern = "[^.]+" |
|
|
|
@ -51,9 +51,9 @@ func newRouteRegexp(tpl string, matchHost, matchPrefix, matchQuery, strictSlash |
|
|
|
} |
|
|
|
} |
|
|
|
varsN := make([]string, len(idxs)/2) |
|
|
|
varsN := make([]string, len(idxs)/2) |
|
|
|
varsR := make([]*regexp.Regexp, len(idxs)/2) |
|
|
|
varsR := make([]*regexp.Regexp, len(idxs)/2) |
|
|
|
pattern := bytes.NewBufferString("^") |
|
|
|
pattern := bytes.NewBufferString("") |
|
|
|
if matchQuery { |
|
|
|
if !matchQuery { |
|
|
|
pattern = bytes.NewBufferString("") |
|
|
|
pattern.WriteByte('^') |
|
|
|
} |
|
|
|
} |
|
|
|
reverse := bytes.NewBufferString("") |
|
|
|
reverse := bytes.NewBufferString("") |
|
|
|
var end int |
|
|
|
var end int |
|
|
|
@ -209,9 +209,9 @@ func braceIndices(s string) ([]int, error) { |
|
|
|
|
|
|
|
|
|
|
|
// routeRegexpGroup groups the route matchers that carry variables.
|
|
|
|
// routeRegexpGroup groups the route matchers that carry variables.
|
|
|
|
type routeRegexpGroup struct { |
|
|
|
type routeRegexpGroup struct { |
|
|
|
host *routeRegexp |
|
|
|
host *routeRegexp |
|
|
|
path *routeRegexp |
|
|
|
path *routeRegexp |
|
|
|
query *routeRegexp |
|
|
|
queries []*routeRegexp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// setMatch extracts the variables from the URL once a route matches.
|
|
|
|
// setMatch extracts the variables from the URL once a route matches.
|
|
|
|
@ -249,10 +249,11 @@ func (v *routeRegexpGroup) setMatch(req *http.Request, m *RouteMatch, r *Route) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Store query string variables.
|
|
|
|
// Store query string variables.
|
|
|
|
if v.query != nil { |
|
|
|
rawQuery := req.URL.RawQuery |
|
|
|
queryVars := v.query.regexp.FindStringSubmatch(req.URL.RawQuery) |
|
|
|
for _, q := range v.queries { |
|
|
|
|
|
|
|
queryVars := q.regexp.FindStringSubmatch(rawQuery) |
|
|
|
if queryVars != nil { |
|
|
|
if queryVars != nil { |
|
|
|
for k, v := range v.query.varsN { |
|
|
|
for k, v := range q.varsN { |
|
|
|
m.Vars[v] = queryVars[k+1] |
|
|
|
m.Vars[v] = queryVars[k+1] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|