@@ -851,6 +851,47 @@ func TestRouterStaticDynamicConflict(t *testing.T) {
851851 assert .Equal (t , 3 , c .Get ("c" ))
852852}
853853
854+ // Issue #1348
855+ func TestRouterParamBacktraceNotFound (t * testing.T ) {
856+ e := New ()
857+ r := e .router
858+
859+ // Add
860+ r .Add (http .MethodGet , "/:param1" , func (c Context ) error {
861+ return nil
862+ })
863+ r .Add (http .MethodGet , "/:param1/foo" , func (c Context ) error {
864+ return nil
865+ })
866+ r .Add (http .MethodGet , "/:param1/bar" , func (c Context ) error {
867+ return nil
868+ })
869+ r .Add (http .MethodGet , "/:param1/bar/:param2" , func (c Context ) error {
870+ return nil
871+ })
872+
873+ c := e .NewContext (nil , nil ).(* context )
874+
875+ //Find
876+ r .Find (http .MethodGet , "/a" , c )
877+ assert .Equal (t , "a" , c .Param ("param1" ))
878+
879+ r .Find (http .MethodGet , "/a/foo" , c )
880+ assert .Equal (t , "a" , c .Param ("param1" ))
881+
882+ r .Find (http .MethodGet , "/a/bar" , c )
883+ assert .Equal (t , "a" , c .Param ("param1" ))
884+
885+ r .Find (http .MethodGet , "/a/bar/b" , c )
886+ assert .Equal (t , "a" , c .Param ("param1" ))
887+ assert .Equal (t , "b" , c .Param ("param2" ))
888+
889+ c = e .NewContext (nil , nil ).(* context )
890+ r .Find (http .MethodGet , "/a/bbbbb" , c )
891+ he := c .handler (c ).(* HTTPError )
892+ assert .Equal (t , http .StatusNotFound , he .Code )
893+ }
894+
854895func testRouterAPI (t * testing.T , api []* Route ) {
855896 e := New ()
856897 r := e .router
0 commit comments