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
435435 return
436436 }
437437
438+ if path == "/" && n .nType == static {
439+ tsr = true
440+ return
441+ }
442+
438443 // No handle found. Check if a handle for this path + a
439444 // trailing slash exists for trailing slash recommendation
440445 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) {
699699 }
700700 }
701701}
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