diff --git a/gin_integration_test.go b/gin_integration_test.go index 9bcc19d4..4f44757d 100644 --- a/gin_integration_test.go +++ b/gin_integration_test.go @@ -402,12 +402,10 @@ func TestRunDynamicRouting(t *testing.T) { router.GET("/", func(c *Context) { c.String(http.StatusOK, "home") }) router.GET("/:cc", func(c *Context) { c.String(http.StatusOK, "/:cc") }) router.GET("/:cc/cc", func(c *Context) { c.String(http.StatusOK, "/:cc/cc") }) - router.GET("/:cc/:dd/ee", func(c *Context) { c.String(http.StatusOK, "/:cc/:dd/ee") }) router.GET("/:cc/:dd/:ee/ff", func(c *Context) { c.String(http.StatusOK, "/:cc/:dd/:ee/ff") }) router.GET("/:cc/:dd/:ee/:ff/gg", func(c *Context) { c.String(http.StatusOK, "/:cc/:dd/:ee/:ff/gg") }) router.GET("/:cc/:dd/:ee/:ff/:gg/hh", func(c *Context) { c.String(http.StatusOK, "/:cc/:dd/:ee/:ff/:gg/hh") }) - router.GET("/get/test/abc/", func(c *Context) { c.String(http.StatusOK, "/get/test/abc/") }) router.GET("/get/:param/abc/", func(c *Context) { c.String(http.StatusOK, "/get/:param/abc/") }) router.GET("/something/:paramname/thirdthing", func(c *Context) { c.String(http.StatusOK, "/something/:paramname/thirdthing") }) diff --git a/tree.go b/tree.go index 94875e77..de2d9cd0 100644 --- a/tree.go +++ b/tree.go @@ -446,7 +446,7 @@ walk: // Outer loop for walking the tree n = n.children[i] // match '/', If this condition is matched, the next route is found - if (len(n.fullPath) != 0 && n.wildChild) || strings.HasSuffix(path, "/") { + if (len(n.fullPath) != 0 && n.wildChild) || path[len(path)-1] == '/' { matchNum++ } continue walk