Merge branch 'master' into mymaster

This commit is contained in:
zhangmj 2024-02-05 10:05:13 +08:00
commit 97d73763ab
2 changed files with 6 additions and 1 deletions

View File

@ -351,7 +351,10 @@ func (n *node) insertChild(path string, fullPath string, handlers HandlersChain)
}
if len(n.path) > 0 && n.path[len(n.path)-1] == '/' {
pathSeg := strings.SplitN(n.children[0].path, "/", 2)[0]
pathSeg := ""
if len(n.children) != 0 {
pathSeg = strings.SplitN(n.children[0].path, "/", 2)[0]
}
panic("catch-all wildcard '" + path +
"' in new path '" + fullPath +
"' conflicts with existing path segment '" + pathSeg +

View File

@ -417,6 +417,8 @@ func TestTreeWildcardConflict(t *testing.T) {
{"/user_:name", false},
{"/id:id", false},
{"/id/:id", false},
{"/static/*file", false},
{"/static/", true},
}
testRoutes(t, routes)
}