Skip to content

Commit

Permalink
Support TSR when wildcard follows named param (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
erichuang1994 committed Sep 21, 2020
1 parent 2d16253 commit fe77dd0
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 @@ -393,7 +393,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.handle != nil)
tsr = (n.path == "/" && n.handle != 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 @@ -392,6 +392,7 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
"/no/a",
"/no/b",
"/api/hello/:name",
"/vendor/:x/*y",
}
for i := range routes {
route := routes[i]
Expand Down Expand Up @@ -420,6 +421,7 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
"/admin/config/",
"/admin/config/permissions/",
"/doc/",
"/vendor/x",
}
for _, route := range tsrRoutes {
handler, _, tsr := tree.getValue(route, nil)
Expand Down

0 comments on commit fe77dd0

Please sign in to comment.