This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit bb945cf authored and committed Nov 24, 2021
1 parent a3f0872 commit bb945cf Copy full SHA for bb945cf
File tree 2 files changed +17
-1
lines changed
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) {
479
479
router .GET ("/a" , func (c * Context ) {})
480
480
w = performRequest (router , http .MethodGet , "/" )
481
481
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 ())
482
497
}
483
498
484
499
func 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
635
635
// Nothing found. We can recommend to redirect to the same URL with an
636
636
// extra trailing slash if a leaf exists for that path
637
637
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 )
639
640
return
640
641
}
641
642
}
You can’t perform that action at this time.
0 commit comments