mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:20:54 +00:00
fix router like /admin/index/ should equal to /admin/index
This commit is contained in:
parent
a7791c2786
commit
3f076f4ca0
13
router.go
13
router.go
@ -146,8 +146,19 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
//first find path from the fixrouters to Improve Performance
|
//first find path from the fixrouters to Improve Performance
|
||||||
for _, route := range p.fixrouters {
|
for _, route := range p.fixrouters {
|
||||||
n := len(requestPath)
|
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) ||
|
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
|
runrouter = route
|
||||||
findrouter = true
|
findrouter = true
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user