@@ -238,23 +238,20 @@ export abstract class ContextKeyExpr {
238
238
private static _deserializeRegexValue ( serializedValue : string ) : RegExp | null {
239
239
240
240
if ( isFalsyOrWhitespace ( serializedValue ) ) {
241
- console . warn ( 'missing regexp-value for =~-expression' ) ;
242
241
return null ;
243
242
}
244
243
245
244
const start = serializedValue . indexOf ( '/' ) ;
246
245
const end = serializedValue . lastIndexOf ( '/' ) ;
247
- if ( start === end || start < 0 /* || to < 0 */ ) {
248
- console . warn ( `bad regexp-value '${ serializedValue } ', missing /-enclosure` ) ;
246
+ if ( start === end || start < 0 ) {
249
247
return null ;
250
248
}
251
249
252
250
const value = serializedValue . slice ( start + 1 , end ) ;
253
251
const caseIgnoreFlag = serializedValue [ end + 1 ] === 'i' ? 'i' : '' ;
254
252
try {
255
253
return new RegExp ( value , caseIgnoreFlag ) ;
256
- } catch ( e ) {
257
- console . warn ( `bad regexp-value '${ serializedValue } ', parse error: ${ e } ` ) ;
254
+ } catch ( _e ) {
258
255
return null ;
259
256
}
260
257
}
@@ -499,25 +496,23 @@ export class Parser {
499
496
500
497
let regex : RegExp | null = null ;
501
498
502
- if ( isFalsyOrWhitespace ( serializedValue ) ) {
503
- console . warn ( 'missing regexp-value for =~-expression' ) ;
504
- } else {
499
+ if ( ! isFalsyOrWhitespace ( serializedValue ) ) {
505
500
const start = serializedValue . indexOf ( '/' ) ;
506
501
const end = serializedValue . lastIndexOf ( '/' ) ;
507
- if ( start === end || start < 0 /* || to < 0 */ ) {
508
- console . warn ( `bad regexp-value '${ serializedValue } ', missing /-enclosure` ) ;
509
- } else {
502
+ if ( start !== end && start >= 0 ) {
510
503
511
504
const value = serializedValue . slice ( start + 1 , end ) ;
512
505
const caseIgnoreFlag = serializedValue [ end + 1 ] === 'i' ? 'i' : '' ;
513
506
try {
514
507
regex = new RegExp ( value , caseIgnoreFlag ) ;
515
- } catch ( e ) {
516
- console . warn ( `bad regexp-value '${ serializedValue } ', parse error: ${ e } ` ) ;
517
- }
508
+ } catch ( _e ) { }
518
509
}
519
510
}
520
511
512
+ if ( regex === null ) {
513
+ throw this . _errExpectedButGot ( 'REGEX' , expr ) ;
514
+ }
515
+
521
516
return ContextKeyRegexExpr . create ( key , regex ) ;
522
517
}
523
518
0 commit comments