diff --git a/gin_integration_test.go b/gin_integration_test.go index 4f44757d..ed7196fd 100644 --- a/gin_integration_test.go +++ b/gin_integration_test.go @@ -395,7 +395,7 @@ func testGetRequestHandler(t *testing.T, h http.Handler, url string) { assert.Equal(t, 200, w.Code, "should get a 200") } -func TestRunDynamicRouting(t *testing.T) { +func TestTreeRunDynamicRouting(t *testing.T) { router := New() router.GET("/aa/*xx", func(c *Context) { c.String(http.StatusOK, "/aa/*xx") }) router.GET("/ab/*xx", func(c *Context) { c.String(http.StatusOK, "/ab/*xx") }) diff --git a/tree.go b/tree.go index b30ef62d..615deb3f 100644 --- a/tree.go +++ b/tree.go @@ -609,9 +609,8 @@ walk: // Outer loop for walking the tree // Nothing found. We can recommend to redirect to the same URL with an // extra trailing slash if a leaf exists for that path - value.tsr = (path == "/") || - (len(prefix) == len(path)+1 && prefix[len(path)] == '/' && - path == prefix[:len(prefix)-1] && n.handlers != nil) + value.tsr = path == "/" || + (path == prefix[:len(prefix)-1] && n.handlers != nil) return } }