tree: Improve wildcard conflict panic reason Fixes #151
diff --git a/tree.go b/tree.go index b735534..ef9d564 100644 --- a/tree.go +++ b/tree.go
@@ -144,16 +144,19 @@ numParams-- // Check if the wildcard matches - if len(path) >= len(n.path) && n.path == path[:len(n.path)] { - // check for longer wildcard, e.g. :name and :names - if len(n.path) >= len(path) || path[len(n.path)] == '/' { - continue walk - } + if len(path) >= len(n.path) && n.path == path[:len(n.path)] && + // Check for longer wildcard, e.g. :name and :names + (len(n.path) >= len(path) || path[len(n.path)] == '/') { + continue walk + } else { + // Wildcard conflict + pathSeg := strings.SplitN(path, "/", 2)[0] + prefix := fullPath[:strings.Index(fullPath, pathSeg)] + n.path + panic("'" + pathSeg + + "' in new path '" + fullPath + "'" + + "' conflicts with existing wildcard '" + n.path + + "' in existing prefix '" + prefix + "'") } - - panic("path segment '" + path + - "' conflicts with existing wildcard '" + n.path + - "' in path '" + fullPath + "'") } c := path[0]