diff --git a/tree.go b/tree.go index c87e0d89..4f2082ee 100644 --- a/tree.go +++ b/tree.go @@ -76,9 +76,10 @@ func countParams(path string) uint8 { type nodeType uint8 const ( - static nodeType = 0 - param nodeType = 1 - catchAll nodeType = 2 + static nodeType = iota // default + root + param + catchAll ) type node struct { @@ -238,6 +239,7 @@ func (n *node) addRoute(path string, handlers HandlersChain) { } } else { // Empty tree n.insertChild(numParams, path, fullPath, handlers) + n.nType = root } } @@ -452,6 +454,11 @@ walk: // Outer loop for walking the tree return } + if path == "/" && n.wildChild && n.nType != root { + tsr = true + return + } + // No handle found. Check if a handle for this path + a // trailing slash exists for trailing slash recommendation for i := 0; i < len(n.indices); i++ {