File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 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 {
551551 error ( ) {
552552 let state : State = this . $to ( ) ;
553553
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+
554559 if ( state . self . abstract )
555560 return `Cannot transition to abstract state '${ state . name } '` ;
556561 if ( ! Param . validates ( state . parameters ( ) , this . params ( ) ) )
Original file line number Diff line number Diff line change @@ -62,6 +62,21 @@ describe('stateService', function () {
6262 . then ( done , done ) ;
6363 } ) ) ;
6464
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+
6580 it ( "should not update the URL in response to synchronizing URL" , ( ( done ) => {
6681 $loc . setUrl ( '/a/b/c' ) ;
6782 spyOn ( $loc , 'setUrl' ) . and . callThrough ( ) ;
You can’t perform that action at this time.
0 commit comments