File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ const parseLine = (() => {
72
72
const re3 = new RegExp ( / \s + / g) ;
73
73
return ( line => line . replace ( re1 , '' ) . replace ( re2 , '' ) . replace ( re3 , '' ) ) ;
74
74
} ) ( ) ;
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;
76
76
77
77
return ( line , options ) => {
78
78
options = options || { } ;
@@ -105,7 +105,7 @@ const parseLine = (() => {
105
105
continue ;
106
106
}
107
107
108
- // Parser JSON commands for TinyG and g2core
108
+ // Parse JSON commands for TinyG and g2core
109
109
if ( letter === '{' ) {
110
110
result . cmds = ( result . cmds || [ ] ) . concat ( line . trim ( ) ) ;
111
111
continue ;
Original file line number Diff line number Diff line change @@ -63,6 +63,16 @@ describe('gcode-parser', () => {
63
63
} ) ;
64
64
} ) ;
65
65
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
+
66
76
describe ( 'Commands' , ( ) => {
67
77
it ( 'should be able to parse $ command (e.g. Grbl).' , ( done ) => {
68
78
const data = parseLine ( '$H $C' ) ;
You can’t perform that action at this time.
0 commit comments