diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/pathtree.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/pathtree.go b/internal/pathtree.go index 7da4c2b..3861c8e 100644 --- a/internal/pathtree.go +++ b/internal/pathtree.go @@ -12,7 +12,7 @@ type PathTree[V any] struct { func (pt PathTree[V]) Match(path string) (*V, map[string]string) { path = strings.TrimPrefix(path, "/") - if path == "" { + if path == "" && pt.root != nil { return pt.root, map[string]string{} } m := pt.tree.Match(strings.Split(path, "/"), nil) @@ -143,9 +143,13 @@ type remainderNode[V any] struct { } func (rn remainderNode[V]) Match(segments []string, m *match[V]) *match[V] { + length := 0 + if m != nil { + length = m.length + } m = &match[V]{ value: &rn.value, - length: m.length, + length: length, prev: m, } if rn.param != "" { |