Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong when wildcard follows named param #2983

Merged
merged 6 commits into from
Dec 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ walk: // Outer loop for walking the tree
// No handle found. Check if a handle for this path + a
// trailing slash exists for TSR recommendation
n = n.children[0]
value.tsr = n.path == "/" && n.handlers != nil
value.tsr = (n.path == "/" && n.handlers != nil) || (n.path == "" && n.indices == "/")
}
return

Expand Down
2 changes: 2 additions & 0 deletions tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
"/blog/:p",
"/posts/:b/:c",
"/posts/b/:c/d/",
"/vendor/:x/*y",
}
for _, route := range routes {
recv := catchPanic(func() {
Expand Down Expand Up @@ -631,6 +632,7 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
"/api/world/abc/",
"/blog/pp/",
"/posts/b/c/d",
"/vendor/x",
}

for _, route := range tsrRoutes {
Expand Down