update value.tsr match rule

This commit is contained in:
qm012 2021-07-06 15:13:50 +08:00
parent 82f3c92ded
commit 085b582bea
2 changed files with 3 additions and 4 deletions

View File

@ -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") })

View File

@ -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
}
}