3a08eec1 by Pengfei Xue

simplify condition test for trailing /

1 parent ecfd11ad
...@@ -575,12 +575,11 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -575,12 +575,11 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
575 } 575 }
576 // pattern /admin url /admin 200 /admin/ 200 576 // pattern /admin url /admin 200 /admin/ 200
577 // pattern /admin/ url /admin 301 /admin/ 200 577 // pattern /admin/ url /admin 301 /admin/ 200
578 if requestPath[n-1] != '/' && len(route.pattern) == n+1 && 578 if requestPath[n-1] != '/' && requestPath+"/" == route.pattern {
579 route.pattern[n] == '/' && route.pattern[:n] == requestPath {
580 http.Redirect(w, r, requestPath+"/", 301) 579 http.Redirect(w, r, requestPath+"/", 301)
581 goto Admin 580 goto Admin
582 } 581 }
583 if requestPath[n-1] == '/' && n >= 2 && requestPath[:n-2] == route.pattern { 582 if requestPath[n-1] == '/' && route.pattern+"/" == requestPath {
584 runMethod = p.getRunMethod(r.Method, context, route) 583 runMethod = p.getRunMethod(r.Method, context, route)
585 if runMethod != "" { 584 if runMethod != "" {
586 runrouter = route.controllerType 585 runrouter = route.controllerType
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!