Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
Support TSR when wildcard follows named param
Browse files Browse the repository at this point in the history
  • Loading branch information
erichuang1994 authored and razonyang committed Sep 21, 2020
1 parent 1490139 commit 0a26903
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,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]
tsr = (n.path == "/" && n.route != nil)
tsr = (n.path == "/" && n.route != 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 @@ -363,6 +363,7 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
"/no/a",
"/no/b",
"/api/hello/:name",
"/vendor/:x/*y",
}
for _, route := range routes {
recv := catchPanic(func() {
Expand All @@ -386,6 +387,7 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
"/admin/config/",
"/admin/config/permissions/",
"/doc/",
"/vendor/x",
}
for _, route := range tsrRoutes {
handler, tsr := tree.getValue(route, nil, false)
Expand Down

0 comments on commit 0a26903

Please sign in to comment.