mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 21:32:11 +08:00
update math condition
This commit is contained in:
parent
23f623829a
commit
ec091bf4d8
@ -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") })
|
||||
|
2
tree.go
2
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user