@@ -337,6 +337,45 @@ func TestRouteParamsByNameWithExtraSlash(t *testing.T) {
337337 assert .Equal (t , "/is/super/great" , wild )
338338}
339339
340+ // TestRouteParamsNotEmpty tests that context parameters will be set
341+ // even if a route with params/wildcards is registered after the context
342+ // initialisation (which happened in a previous requets).
343+ func TestRouteParamsNotEmpty (t * testing.T ) {
344+ name := ""
345+ lastName := ""
346+ wild := ""
347+ router := New ()
348+
349+ w := PerformRequest (router , http .MethodGet , "/test/john/smith/is/super/great" )
350+
351+ assert .Equal (t , http .StatusNotFound , w .Code )
352+
353+ router .GET ("/test/:name/:last_name/*wild" , func (c * Context ) {
354+ name = c .Params .ByName ("name" )
355+ lastName = c .Params .ByName ("last_name" )
356+ var ok bool
357+ wild , ok = c .Params .Get ("wild" )
358+
359+ assert .True (t , ok )
360+ assert .Equal (t , name , c .Param ("name" ))
361+ assert .Equal (t , lastName , c .Param ("last_name" ))
362+
363+ assert .Empty (t , c .Param ("wtf" ))
364+ assert .Empty (t , c .Params .ByName ("wtf" ))
365+
366+ wtf , ok := c .Params .Get ("wtf" )
367+ assert .Empty (t , wtf )
368+ assert .False (t , ok )
369+ })
370+
371+ w = PerformRequest (router , http .MethodGet , "/test/john/smith/is/super/great" )
372+
373+ assert .Equal (t , http .StatusOK , w .Code )
374+ assert .Equal (t , "john" , name )
375+ assert .Equal (t , "smith" , lastName )
376+ assert .Equal (t , "/is/super/great" , wild )
377+ }
378+
340379// TestHandleStaticFile - ensure the static file handles properly
341380func TestRouteStaticFile (t * testing.T ) {
342381 // SETUP file
0 commit comments