|
|
|
@ -100,6 +100,7 @@ func newRouteRegexp(tpl string, matchHost, matchPrefix, strictSlash bool) (*rout |
|
|
|
return &routeRegexp{ |
|
|
|
return &routeRegexp{ |
|
|
|
template: template, |
|
|
|
template: template, |
|
|
|
matchHost: matchHost, |
|
|
|
matchHost: matchHost, |
|
|
|
|
|
|
|
strictSlash: strictSlash, |
|
|
|
regexp: reg, |
|
|
|
regexp: reg, |
|
|
|
reverse: reverse.String(), |
|
|
|
reverse: reverse.String(), |
|
|
|
varsN: varsN, |
|
|
|
varsN: varsN, |
|
|
|
@ -114,6 +115,8 @@ type routeRegexp struct { |
|
|
|
template string |
|
|
|
template string |
|
|
|
// True for host match, false for path match.
|
|
|
|
// True for host match, false for path match.
|
|
|
|
matchHost bool |
|
|
|
matchHost bool |
|
|
|
|
|
|
|
// The strictSlash value defined on the route, but disabled if PathPrefix was used.
|
|
|
|
|
|
|
|
strictSlash bool |
|
|
|
// Expanded regexp.
|
|
|
|
// Expanded regexp.
|
|
|
|
regexp *regexp.Regexp |
|
|
|
regexp *regexp.Regexp |
|
|
|
// Reverse template.
|
|
|
|
// Reverse template.
|
|
|
|
@ -216,7 +219,7 @@ func (v *routeRegexpGroup) setMatch(req *http.Request, m *RouteMatch, r *Route) |
|
|
|
m.Vars[v] = pathVars[k+1] |
|
|
|
m.Vars[v] = pathVars[k+1] |
|
|
|
} |
|
|
|
} |
|
|
|
// Check if we should redirect.
|
|
|
|
// Check if we should redirect.
|
|
|
|
if r.strictSlash { |
|
|
|
if v.path.strictSlash { |
|
|
|
p1 := strings.HasSuffix(req.URL.Path, "/") |
|
|
|
p1 := strings.HasSuffix(req.URL.Path, "/") |
|
|
|
p2 := strings.HasSuffix(v.path.template, "/") |
|
|
|
p2 := strings.HasSuffix(v.path.template, "/") |
|
|
|
if p1 != p2 { |
|
|
|
if p1 != p2 { |
|
|
|
|