diff --git a/router.go b/router.go index 73f0b68b..aae99a37 100644 --- a/router.go +++ b/router.go @@ -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 diff --git a/router_test.go b/router_test.go index a5d53c0a..f084fb98 100644 --- a/router_test.go +++ b/router_test.go @@ -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)