a1e29b0b by astaxie

Merge pull request #422 from pengfei-xue/devel

simplify condition test for trailing /
2 parents 984b0cbf 3a08eec1
...@@ -583,12 +583,11 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -583,12 +583,11 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
583 } 583 }
584 // pattern /admin url /admin 200 /admin/ 200 584 // pattern /admin url /admin 200 /admin/ 200
585 // pattern /admin/ url /admin 301 /admin/ 200 585 // pattern /admin/ url /admin 301 /admin/ 200
586 if requestPath[n-1] != '/' && len(route.pattern) == n+1 && 586 if requestPath[n-1] != '/' && requestPath+"/" == route.pattern {
587 route.pattern[n] == '/' && route.pattern[:n] == requestPath {
588 http.Redirect(w, r, requestPath+"/", 301) 587 http.Redirect(w, r, requestPath+"/", 301)
589 goto Admin 588 goto Admin
590 } 589 }
591 if requestPath[n-1] == '/' && n >= 2 && requestPath[:n-2] == route.pattern { 590 if requestPath[n-1] == '/' && route.pattern+"/" == requestPath {
592 runMethod = p.getRunMethod(r.Method, context, route) 591 runMethod = p.getRunMethod(r.Method, context, route)
593 if runMethod != "" { 592 if runMethod != "" {
594 runrouter = route.controllerType 593 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!