From 3f076f4ca0b05c270c9c41881847749da97207e9 Mon Sep 17 00:00:00 2001 From: astaxie Date: Wed, 19 Dec 2012 16:38:25 +0800 Subject: [PATCH] fix router like /admin/index/ should equal to /admin/index --- router.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/router.go b/router.go index 82d71dc0..dd665776 100644 --- a/router.go +++ b/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 for _, route := range p.fixrouters { 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) || - (len(route.pattern) >= n && requestPath == route.pattern) { + (len(route.pattern) >= n && requestPath[0:n-1] == route.pattern) { runrouter = route findrouter = true break