diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-05-01 21:42:26 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-05-01 21:42:26 -0600 |
commit | 0d5e5589140bec6c8a834b7f896258d62e739bfe (patch) | |
tree | 4db93589afe55af2329d9422f743f9ed66ff1119 /internal | |
parent | fdc6d5e60137393c4c507c35556647f3dafc917a (diff) |
fixes to /*remainder route segments
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 != "" { |