simplify condition test for trailing /
Showing
1 changed file
with
2 additions
and
3 deletions
| ... | @@ -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 | ... | ... |
-
Please register or sign in to post a comment