File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -479,6 +479,21 @@ func TestRouterNotFound(t *testing.T) {
479479 router .GET ("/a" , func (c * Context ) {})
480480 w = performRequest (router , http .MethodGet , "/" )
481481 assert .Equal (t , http .StatusNotFound , w .Code )
482+
483+ // Reproduction test for the bug of issue #2843
484+ router = New ()
485+ router .NoRoute (func (c * Context ) {
486+ if c .Request .RequestURI == "/login" {
487+ c .String (200 , "login" )
488+ }
489+ })
490+ router .GET ("/logout" , func (c * Context ) {
491+ c .String (200 , "logout" )
492+ })
493+ w = performRequest (router , http .MethodGet , "/login" )
494+ assert .Equal (t , "login" , w .Body .String ())
495+ w = performRequest (router , http .MethodGet , "/logout" )
496+ assert .Equal (t , "logout" , w .Body .String ())
482497}
483498
484499func TestRouterStaticFSNotFound (t * testing.T ) {
Original file line number Diff line number Diff line change @@ -635,7 +635,8 @@ walk: // Outer loop for walking the tree
635635 // Nothing found. We can recommend to redirect to the same URL with an
636636 // extra trailing slash if a leaf exists for that path
637637 value .tsr = path == "/" ||
638- (len (prefix ) == len (path )+ 1 && n .handlers != nil )
638+ (len (prefix ) == len (path )+ 1 && prefix [len (path )] == '/' &&
639+ path == prefix [:len (prefix )- 1 ] && n .handlers != nil )
639640 return
640641 }
641642}
You can’t perform that action at this time.
0 commit comments