1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00

tests and fix for findChildByKind executed on nil node

This commit is contained in:
Michał Adamski 2019-03-01 08:27:11 +01:00
parent 802fb5bba6
commit e1d21a73cf
2 changed files with 9 additions and 0 deletions

View File

@ -218,6 +218,9 @@ func (n *node) findChildWithLabel(l byte) *node {
}
func (n *node) findChildByKind(t kind) *node {
if n == nil {
return nil
}
for _, c := range n.children {
if c.kind == t {
return c

View File

@ -756,6 +756,12 @@ func TestRouterPriorityNotFound(t *testing.T) {
c.Set("b", 2)
return nil
})
r.Add(http.MethodGet, "/:lang/", func(c Context) error {
return nil
})
r.Add(http.MethodGet, "/:lang/dupa", func(c Context) error {
return nil
})
// Find
r.Find(http.MethodGet, "/a/foo", c)