File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -435,6 +435,11 @@ walk: // Outer loop for walking the tree
435
435
return
436
436
}
437
437
438
+ if path == "/" && n .nType == static {
439
+ tsr = true
440
+ return
441
+ }
442
+
438
443
// No handle found. Check if a handle for this path + a
439
444
// trailing slash exists for trailing slash recommendation
440
445
for i , c := range []byte (n .indices ) {
Original file line number Diff line number Diff line change @@ -699,3 +699,23 @@ func TestTreeWildcardConflictEx(t *testing.T) {
699
699
}
700
700
}
701
701
}
702
+
703
+ func TestRedirectTrailingSlash (t * testing.T ) {
704
+ var data = []struct {
705
+ path string
706
+ }{
707
+ {"/hello/:name" },
708
+ {"/hello/:name/123" },
709
+ {"/hello/:name/234" },
710
+ }
711
+
712
+ node := & node {}
713
+ for _ , item := range data {
714
+ node .addRoute (item .path , fakeHandler ("test" ))
715
+ }
716
+
717
+ _ , _ , tsr := node .getValue ("/hello/abx/" , nil )
718
+ if tsr != true {
719
+ t .Fatalf ("want true, is false" )
720
+ }
721
+ }
You can’t perform that action at this time.
0 commit comments