File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ pathStateMachine[IN_SUB_PATH] = {
9090 'ident' : [ IN_SUB_PATH , APPEND ] ,
9191 '0' : [ IN_SUB_PATH , APPEND ] ,
9292 'number' : [ IN_SUB_PATH , APPEND ] ,
93- 'ws' : [ AFTER_ELEMENT , PUSH ] ,
93+ 'ws' : [ AFTER_ELEMENT ] ,
9494 ']' : [ IN_PATH , PUSH ]
9595}
9696
@@ -99,8 +99,6 @@ pathStateMachine[AFTER_ELEMENT] = {
9999 ']' : [ IN_PATH , PUSH ]
100100}
101101
102- function noop ( ) { }
103-
104102/**
105103 * Determine the type of a character in a keypath.
106104 *
@@ -213,14 +211,16 @@ function parsePath (path) {
213211 }
214212
215213 mode = transition [ 0 ]
216- action = actions [ transition [ 1 ] ] || noop
217- newChar = transition [ 2 ]
218- newChar = newChar === undefined
219- ? c
220- : newChar === '*'
221- ? newChar + c
222- : newChar
223- action ( )
214+ action = actions [ transition [ 1 ] ]
215+ if ( action ) {
216+ newChar = transition [ 2 ]
217+ newChar = newChar === undefined
218+ ? c
219+ : newChar === '*'
220+ ? newChar + c
221+ : newChar
222+ action ( )
223+ }
224224
225225 if ( mode === AFTER_PATH ) {
226226 keys . raw = path
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ describe('Path Parser', function () {
4545 assertPath ( 'foo["b\\"az"]' , [ 'foo' , 'b"az' ] )
4646 assertPath ( "foo['b\\'az']" , [ 'foo' , "b'az" ] )
4747 assertPath ( 'a[b][c]' , [ 'a' , '*b' , '*c' ] )
48+ assertPath ( 'a[ b ][ c ]' , [ 'a' , '*b' , '*c' ] )
4849 } )
4950
5051 it ( 'handle invalid paths' , function ( ) {
You can’t perform that action at this time.
0 commit comments