Merge pull request #422 from pengfei-xue/devel
simplify condition test for trailing /
Showing
1 changed file
with
2 additions
and
3 deletions
| ... | @@ -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 | ... | ... |
-
Please register or sign in to post a comment