@@ -38,7 +38,7 @@ const regExpFilter = (regExp, separator) => {
38
38
} ;
39
39
40
40
const filterBase =
41
- ( { specialAction = 'accept' , defaultAction = 'ignore' , nonCheckableAction = 'ignore ' , transition} = { } ) =>
41
+ ( { specialAction = 'accept' , defaultAction = 'ignore' , nonCheckableAction = 'process-key ' , transition} = { } ) =>
42
42
options => {
43
43
const once = options ?. once ,
44
44
separator = options ?. pathSeparator || '.' ;
@@ -70,20 +70,35 @@ const filterBase =
70
70
// process the optional value token (unfinished)
71
71
if ( optionalToken ) {
72
72
if ( optionalToken === chunk . name ) {
73
- const returnToken = state === 'accept-value' ? chunk : none ;
73
+ let returnToken = none ;
74
+ switch ( state ) {
75
+ case 'accept-value' :
76
+ returnToken = chunk ;
77
+ state = once ? 'pass' : 'check' ;
78
+ break ;
79
+ case 'process-key' :
80
+ stack [ stack . length - 1 ] = chunk . value ;
81
+ state = 'check' ;
82
+ break ;
83
+ default :
84
+ state = once ? 'pass' : 'check' ;
85
+ break ;
86
+ }
74
87
optionalToken = '' ;
75
- state = once ? 'pass' : 'check' ;
76
88
return returnToken ;
77
89
}
78
90
optionalToken = '' ;
79
- state = once ? 'pass' : 'check' ;
91
+ state = once && state !== 'process-key' ? 'pass' : 'check' ;
80
92
}
81
93
82
94
let returnToken = none ;
83
95
84
96
recheck: for ( ; ; ) {
85
97
// accept/reject tokens
86
98
switch ( state ) {
99
+ case 'process-key' :
100
+ if ( chunk . name === 'endKey' ) optionalToken = 'keyValue' ;
101
+ return none ;
87
102
case 'pass' :
88
103
return none ;
89
104
case 'accept' :
@@ -170,13 +185,17 @@ const filterBase =
170
185
171
186
endToken = stopTokens [ chunk . name ] || '' ;
172
187
switch ( action ) {
188
+ case 'process-key' :
189
+ if ( chunk . name === 'startKey' ) {
190
+ state = 'process-key' ;
191
+ continue recheck;
192
+ }
193
+ break ;
173
194
case 'accept-token' :
174
- if ( endToken ) {
175
- if ( optionalTokens [ endToken ] ) {
176
- state = 'accept-value' ;
177
- startTransition = ! ! transition ;
178
- continue recheck;
179
- }
195
+ if ( endToken && optionalTokens [ endToken ] ) {
196
+ state = 'accept-value' ;
197
+ startTransition = ! ! transition ;
198
+ continue recheck;
180
199
}
181
200
if ( transition ) returnToken = transition ( stack , chunk , action , sanitizedOptions ) ;
182
201
if ( returnToken === none ) {
0 commit comments