From 7d41987313dbfc002277c129c539e410587fd439 Mon Sep 17 00:00:00 2001 From: thinkerou Date: Sun, 3 Jul 2022 16:50:15 +0800 Subject: [PATCH] sync httprouter for fix bug --- tree.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tree.go b/tree.go index 956bf4dd..3f34b8ee 100644 --- a/tree.go +++ b/tree.go @@ -107,7 +107,8 @@ func countSections(path string) uint16 { type nodeType uint8 const ( - root nodeType = iota + 1 + static nodeType = iota + root param catchAll ) @@ -173,6 +174,7 @@ walk: child := node{ path: n.path[i:], wildChild: n.wildChild, + nType: static, indices: n.indices, children: n.children, handlers: n.handlers, @@ -604,6 +606,11 @@ walk: // Outer loop for walking the tree return } + if path == "/" && n.nType == static { + value.tsr = true + return + } + // No handle found. Check if a handle for this path + a // trailing slash exists for trailing slash recommendation for i, c := range []byte(n.indices) {