Skip to content

Commit

Permalink
update math condition
Browse files Browse the repository at this point in the history
  • Loading branch information
qm012 committed Jul 5, 2021
1 parent 23f6238 commit ec091bf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 0 additions & 2 deletions gin_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") })
Expand Down
2 changes: 1 addition & 1 deletion tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ec091bf

Please sign in to comment.