Skip to content

Commit deb81c1

Browse files
committed
fix: wildcard node should be the last child.
1 parent c3d1092 commit deb81c1

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ walk: // Outer loop for walking the tree
833833
return nil
834834
}
835835

836-
n = n.children[0]
836+
n = n.children[len(n.children)-1]
837837
switch n.nType {
838838
case param:
839839
// Find param end (either '/' or path end)

tree_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,8 @@ func TestTreeFindCaseInsensitivePath(t *testing.T) {
751751
"/w/𠜎", // 4 byte
752752
"/w/𠜏/", // 4 byte
753753
longPath,
754+
"/param/same/:id",
755+
"/param/same/1",
754756
}
755757

756758
for _, route := range routes {
@@ -844,6 +846,7 @@ func TestTreeFindCaseInsensitivePath(t *testing.T) {
844846
{"/w/𠜎/", "/w/𠜎", true, true},
845847
{"/w/𠜏", "/w/𠜏/", true, true},
846848
{lOngPath, longPath, true, true},
849+
{"/param/same/prefix/noexist", "", false, false},
847850
}
848851
// With fixTrailingSlash = true
849852
for _, test := range tests {

0 commit comments

Comments
 (0)