File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -551,6 +551,11 @@ export class Transition implements IHookRegistry {
551
551
error ( ) {
552
552
let state : State = this . $to ( ) ;
553
553
554
+ let redirects = 0 , trans : Transition = this ;
555
+ while ( ( trans = trans . redirectedFrom ( ) ) != null ) {
556
+ if ( ++ redirects > 20 ) return `Too many Transition redirects (20+)` ;
557
+ }
558
+
554
559
if ( state . self . abstract )
555
560
return `Cannot transition to abstract state '${ state . name } '` ;
556
561
if ( ! Param . validates ( state . parameters ( ) , this . params ( ) ) )
Original file line number Diff line number Diff line change @@ -62,6 +62,21 @@ describe('stateService', function () {
62
62
. then ( done , done ) ;
63
63
} ) ) ;
64
64
65
+ it ( 'should error after 20+ redirects' , ( done ) => {
66
+ let errors = [ ] ;
67
+ $transitions . onEnter ( { entering : "D" } , trans => trans . router . stateService . target ( 'D' ) ) ;
68
+ $transitions . onError ( { } , trans => { errors . push ( trans . error ( ) ) } ) ;
69
+
70
+ $state . defaultErrorHandler ( function ( ) { } ) ;
71
+
72
+ $state . go ( "D" ) . catch ( err => {
73
+ expect ( errors . length ) . toBe ( 21 ) ;
74
+ expect ( err . message ) . toContain ( 'Too many Transition redirects' ) ;
75
+ done ( ) ;
76
+ } ) ;
77
+ } )
78
+
79
+
65
80
it ( "should not update the URL in response to synchronizing URL" , ( ( done ) => {
66
81
$loc . setUrl ( '/a/b/c' ) ;
67
82
spyOn ( $loc , 'setUrl' ) . and . callThrough ( ) ;
You can’t perform that action at this time.
0 commit comments