Skip to content

Commit fe77dd0

Browse files
Support TSR when wildcard follows named param (julienschmidt#321)
1 parent 2d16253 commit fe77dd0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ walk: // Outer loop for walking the tree
393393
// No handle found. Check if a handle for this path + a
394394
// trailing slash exists for TSR recommendation
395395
n = n.children[0]
396-
tsr = (n.path == "/" && n.handle != nil)
396+
tsr = (n.path == "/" && n.handle != nil) || (n.path == "" && n.indices == "/")
397397
}
398398

399399
return

tree_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
392392
"/no/a",
393393
"/no/b",
394394
"/api/hello/:name",
395+
"/vendor/:x/*y",
395396
}
396397
for i := range routes {
397398
route := routes[i]
@@ -420,6 +421,7 @@ func TestTreeTrailingSlashRedirect(t *testing.T) {
420421
"/admin/config/",
421422
"/admin/config/permissions/",
422423
"/doc/",
424+
"/vendor/x",
423425
}
424426
for _, route := range tsrRoutes {
425427
handler, _, tsr := tree.getValue(route, nil)

0 commit comments

Comments
 (0)