1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 06:20:54 +00:00

fix router like /admin/index/ should equal to /admin/index

This commit is contained in:
astaxie 2012-12-19 16:38:25 +08:00
parent a7791c2786
commit 3f076f4ca0

View File

@ -146,8 +146,19 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
//first find path from the fixrouters to Improve Performance
for _, route := range p.fixrouters {
n := len(requestPath)
//route like "/"
if n == 1 {
if requestPath == route.pattern {
runrouter = route
findrouter = true
break
} else {
continue
}
}
if (requestPath[n-1] != '/' && route.pattern == requestPath) ||
(len(route.pattern) >= n && requestPath == route.pattern) {
(len(route.pattern) >= n && requestPath[0:n-1] == route.pattern) {
runrouter = route
findrouter = true
break