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] = {
90
90
'ident' : [ IN_SUB_PATH , APPEND ] ,
91
91
'0' : [ IN_SUB_PATH , APPEND ] ,
92
92
'number' : [ IN_SUB_PATH , APPEND ] ,
93
- 'ws' : [ AFTER_ELEMENT , PUSH ] ,
93
+ 'ws' : [ AFTER_ELEMENT ] ,
94
94
']' : [ IN_PATH , PUSH ]
95
95
}
96
96
@@ -99,8 +99,6 @@ pathStateMachine[AFTER_ELEMENT] = {
99
99
']' : [ IN_PATH , PUSH ]
100
100
}
101
101
102
- function noop ( ) { }
103
-
104
102
/**
105
103
* Determine the type of a character in a keypath.
106
104
*
@@ -213,14 +211,16 @@ function parsePath (path) {
213
211
}
214
212
215
213
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
+ }
224
224
225
225
if ( mode === AFTER_PATH ) {
226
226
keys . raw = path
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ describe('Path Parser', function () {
45
45
assertPath ( 'foo["b\\"az"]' , [ 'foo' , 'b"az' ] )
46
46
assertPath ( "foo['b\\'az']" , [ 'foo' , "b'az" ] )
47
47
assertPath ( 'a[b][c]' , [ 'a' , '*b' , '*c' ] )
48
+ assertPath ( 'a[ b ][ c ]' , [ 'a' , '*b' , '*c' ] )
48
49
} )
49
50
50
51
it ( 'handle invalid paths' , function ( ) {
You can’t perform that action at this time.
0 commit comments