From 802125c83d009cc455689384c3ea6f5f9f569f9b Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Fri, 22 Dec 2023 18:36:39 +0530 Subject: [PATCH] fix: catch-all conflicting wildcard --- tree.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tree.go b/tree.go index 7b1e008b..c354c44e 100644 --- a/tree.go +++ b/tree.go @@ -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 +