File tree Expand file tree Collapse file tree 6 files changed +28
-9
lines changed
lib/modules/page/task-actions
src/modules/page/task-actions Expand file tree Collapse file tree 6 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ var Type = {
1010} ;
1111function handleActionString ( actionString ) {
1212 return new Promise ( function ( resolve , reject ) {
13+ if ( typeof actionString !== 'string' ) {
14+ reject ( actionString ) ;
15+ }
1316 var command = parser_1 . getCommand ( actionString ) ;
1417 var params = parser_1 . getParams ( actionString ) ;
1518 switch ( command ) {
@@ -45,7 +48,7 @@ function handleActionString(actionString) {
4548 reject ( false ) ;
4649 }
4750 } ) . catch ( function ( err ) {
48- console . error ( 'Error with editor ' , err ) ;
51+ console . error ( 'Error handling action string ' , err ) ;
4952 } ) ;
5053}
5154Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ function handleTaskActions(actions) {
44 var next = actions . shift ( ) ;
55 if ( next && next . length ) {
66 next . reduce ( function ( total , curr ) {
7+ if ( ! curr || ! curr . length ) {
8+ return total ;
9+ }
710 return total . then ( function ( ) { return handle_action_string_1 . default ( curr ) ; } ) ;
811 } , Promise . resolve ( ) ) ;
912 }
Original file line number Diff line number Diff line change @@ -4,19 +4,22 @@ function getCommand(actionString) {
44 var command = actionString . substring ( 0 , actionString . indexOf ( '(' ) ) ;
55 if ( ! command . length ) {
66 console . log ( 'Error loading editor action command ' , actionString ) ;
7+ return '' ;
78 }
8- else {
9- return command ;
10- }
9+ return command ;
1110}
1211exports . getCommand = getCommand ;
1312function getParams ( actionString ) {
13+ if ( typeof actionString !== 'string' ) {
14+ console . log ( 'Error in tutorial with action command. Expected a string but received ' , actionString ) ;
15+ return [ ] ;
16+ }
1417 var parser = new parse_params_1 . default ( ) ;
1518 var command = getCommand ( actionString ) ;
1619 var params = actionString . substring ( command . length + 1 , actionString . length - 1 ) ;
1720 if ( ! params . length ) {
1821 console . error ( 'Error loading editor action params ' , actionString ) ;
19- return null ;
22+ return [ ] ;
2023 }
2124 var paramsList = parser . getParams ( params ) ;
2225 return paramsList ;
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ export default function handleActionString(
1414 actionString : string
1515) : Promise < void > {
1616 return new Promise ( ( resolve , reject ) => {
17+ if ( typeof actionString !== 'string' ) {
18+ reject ( actionString ) ;
19+ }
1720 const command : string = getCommand ( actionString ) ;
1821 const params : string [ ] = getParams ( actionString ) ;
1922
@@ -63,6 +66,6 @@ export default function handleActionString(
6366 reject ( false ) ;
6467 }
6568 } ) . catch ( ( err ) => {
66- console . error ( 'Error with editor ' , err ) ;
69+ console . error ( 'Error handling action string ' , err ) ;
6770 } ) ;
6871}
Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ export default function handleTaskActions(actions: string[][]): void {
55 if ( next && next . length ) {
66 // resolve promises in order
77 next . reduce ( ( total : Promise < any > , curr : string ) => {
8+ if ( ! curr || ! curr . length ) {
9+ return total ;
10+ }
811 return total . then ( ( ) => handleActionString ( curr ) ) ;
912 } , Promise . resolve ( ) ) ;
1013 }
Original file line number Diff line number Diff line change @@ -5,19 +5,23 @@ export function getCommand(actionString: string): string {
55 let command = actionString . substring ( 0 , actionString . indexOf ( '(' ) ) ;
66 if ( ! command . length ) {
77 console . log ( 'Error loading editor action command ' , actionString ) ;
8- } else {
9- return command ;
8+ return '' ;
109 }
10+ return command ;
1111}
1212
1313export function getParams ( actionString : string ) : string [ ] {
14+ if ( typeof actionString !== 'string' ) {
15+ console . log ( 'Error in tutorial with action command. Expected a string but received ' , actionString ) ;
16+ return [ ] ;
17+ }
1418 // content in brackets, split by comma
1519 let parser = new ParseParams ( ) ;
1620 let command = getCommand ( actionString ) ;
1721 let params = actionString . substring ( command . length + 1 , actionString . length - 1 ) ; // trim brackets
1822 if ( ! params . length ) {
1923 console . error ( 'Error loading editor action params ' , actionString ) ;
20- return null ;
24+ return [ ] ;
2125 }
2226 let paramsList : string [ ] = parser . getParams ( params ) ;
2327 return paramsList ;
You can’t perform that action at this time.
0 commit comments