forked from mirror/gin
fix: wrong when wildcard follows named param (#2983)
This commit is contained in:
parent
e56d18f19d
commit
7d189814cb
2
tree.go
2
tree.go
|
@ -535,7 +535,7 @@ walk: // Outer loop for walking the tree
|
||||||
// No handle found. Check if a handle for this path + a
|
// No handle found. Check if a handle for this path + a
|
||||||
// trailing slash exists for TSR recommendation
|
// trailing slash exists for TSR recommendation
|
||||||
n = n.children[0]
|
n = n.children[0]
|
||||||
value.tsr = n.path == "/" && n.handlers != nil
|
value.tsr = (n.path == "/" && n.handlers != nil) || (n.path == "" && n.indices == "/")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -595,6 +595,7 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
|
||||||
"/blog/:p",
|
"/blog/:p",
|
||||||
"/posts/:b/:c",
|
"/posts/:b/:c",
|
||||||
"/posts/b/:c/d/",
|
"/posts/b/:c/d/",
|
||||||
|
"/vendor/:x/*y",
|
||||||
}
|
}
|
||||||
for _, route := range routes {
|
for _, route := range routes {
|
||||||
recv := catchPanic(func() {
|
recv := catchPanic(func() {
|
||||||
|
@ -631,6 +632,7 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
|
||||||
"/api/world/abc/",
|
"/api/world/abc/",
|
||||||
"/blog/pp/",
|
"/blog/pp/",
|
||||||
"/posts/b/c/d",
|
"/posts/b/c/d",
|
||||||
|
"/vendor/x",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, route := range tsrRoutes {
|
for _, route := range tsrRoutes {
|
||||||
|
|
Loading…
Reference in New Issue