File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ const parseLine = (() => {
7272 const re3 = new RegExp ( / \s + / g) ;
7373 return ( line => line . replace ( re1 , '' ) . replace ( re2 , '' ) . replace ( re3 , '' ) ) ;
7474 } ) ( ) ;
75- const re = / ( % .* ) | ( { .* ) | ( (?: \$ \$ ) | (?: \$ [ a - z A - Z 0 - 9 # ] * ) ) | ( [ a - z A - Z ] [ 0 - 9 \+ \- \. ] * ) | ( \* [ 0 - 9 ] + ) / igm;
75+ const re = / ( % .* ) | ( { .* ) | ( (?: \$ \$ ) | (?: \$ [ a - z A - Z 0 - 9 # ] * ) ) | ( [ a - z A - Z ] [ 0 - 9 \+ \- \. ] + ) | ( \* [ 0 - 9 ] + ) / igm;
7676
7777 return ( line , options ) => {
7878 options = options || { } ;
@@ -105,7 +105,7 @@ const parseLine = (() => {
105105 continue ;
106106 }
107107
108- // Parser JSON commands for TinyG and g2core
108+ // Parse JSON commands for TinyG and g2core
109109 if ( letter === '{' ) {
110110 result . cmds = ( result . cmds || [ ] ) . concat ( line . trim ( ) ) ;
111111 continue ;
Original file line number Diff line number Diff line change @@ -63,6 +63,16 @@ describe('gcode-parser', () => {
6363 } ) ;
6464 } ) ;
6565
66+ describe ( 'Invalid G-code words' , ( ) => {
67+ it ( 'should ignore invalid g-code words' , ( done ) => {
68+ const data = parseLine ( 'messed up' ) ;
69+ expect ( data ) . to . be . an ( 'object' ) ;
70+ expect ( data . line ) . to . be . equal ( 'messed up' ) ;
71+ expect ( data . words ) . to . be . empty ;
72+ done ( ) ;
73+ } ) ;
74+ } ) ;
75+
6676 describe ( 'Commands' , ( ) => {
6777 it ( 'should be able to parse $ command (e.g. Grbl).' , ( done ) => {
6878 const data = parseLine ( '$H $C' ) ;
You can’t perform that action at this time.
0 commit comments