@@ -287,10 +287,6 @@ function initSearch(rawSearchIndex) {
287
287
}
288
288
}
289
289
290
- function isWhitespace ( c ) {
291
- return " \t\n\r" . indexOf ( c ) !== - 1 ;
292
- }
293
-
294
290
function isSpecialStartCharacter ( c ) {
295
291
return "<\"" . indexOf ( c ) !== - 1 ;
296
292
}
@@ -408,7 +404,7 @@ function initSearch(rawSearchIndex) {
408
404
* @return {boolean }
409
405
*/
410
406
function isPathSeparator ( c ) {
411
- return c === ":" || isWhitespace ( c ) ;
407
+ return c === ":" || c === " " ;
412
408
}
413
409
414
410
/**
@@ -425,7 +421,7 @@ function initSearch(rawSearchIndex) {
425
421
const c = parserState . userQuery [ pos - 1 ] ;
426
422
if ( c === lookingFor ) {
427
423
return true ;
428
- } else if ( ! isWhitespace ( c ) ) {
424
+ } else if ( c !== " " ) {
429
425
break ;
430
426
}
431
427
pos -= 1 ;
@@ -454,7 +450,7 @@ function initSearch(rawSearchIndex) {
454
450
function skipWhitespace ( parserState ) {
455
451
while ( parserState . pos < parserState . userQuery . length ) {
456
452
const c = parserState . userQuery [ parserState . pos ] ;
457
- if ( ! isWhitespace ( c ) ) {
453
+ if ( c !== " " ) {
458
454
break ;
459
455
}
460
456
parserState . pos += 1 ;
@@ -473,8 +469,6 @@ function initSearch(rawSearchIndex) {
473
469
const path = name . trim ( ) ;
474
470
if ( path . length === 0 && generics . length === 0 ) {
475
471
throw [ "Unexpected " , parserState . userQuery [ parserState . pos ] ] ;
476
- } else if ( path === "*" ) {
477
- throw [ "Unexpected " , "*" ] ;
478
472
}
479
473
if ( query . literalSearch && parserState . totalElems - parserState . genericsElems > 0 ) {
480
474
throw [ "Cannot have more than one element if you use quotes" ] ;
@@ -512,18 +506,15 @@ function initSearch(rawSearchIndex) {
512
506
bindingName,
513
507
} ;
514
508
}
509
+ const quadcolon = / : : \s * : : / . exec ( path ) ;
515
510
if ( path . startsWith ( "::" ) ) {
516
511
throw [ "Paths cannot start with " , "::" ] ;
517
512
} else if ( path . endsWith ( "::" ) ) {
518
513
throw [ "Paths cannot end with " , "::" ] ;
519
- } else if ( path . includes ( "::::" ) ) {
520
- throw [ "Unexpected " , "::::" ] ;
521
- } else if ( path . includes ( " ::" ) ) {
522
- throw [ "Unexpected " , " ::" ] ;
523
- } else if ( path . includes ( ":: " ) ) {
524
- throw [ "Unexpected " , ":: " ] ;
525
- }
526
- const pathSegments = path . split ( / : : | \s + / ) ;
514
+ } else if ( quadcolon !== null ) {
515
+ throw [ "Unexpected " , quadcolon [ 0 ] ] ;
516
+ }
517
+ const pathSegments = path . split ( / (?: : : \s * ) | (?: \s + (?: : : \s * ) ? ) / ) ;
527
518
// In case we only have something like `<p>`, there is no name.
528
519
if ( pathSegments . length === 0 || ( pathSegments . length === 1 && pathSegments [ 0 ] === "" ) ) {
529
520
if ( generics . length > 0 || prevIs ( parserState , ">" ) ) {
@@ -604,7 +595,7 @@ function initSearch(rawSearchIndex) {
604
595
} else {
605
596
while ( parserState . pos + 1 < parserState . length ) {
606
597
const next_c = parserState . userQuery [ parserState . pos + 1 ] ;
607
- if ( ! isWhitespace ( next_c ) ) {
598
+ if ( next_c !== " " ) {
608
599
break ;
609
600
}
610
601
parserState . pos += 1 ;
@@ -958,7 +949,7 @@ function initSearch(rawSearchIndex) {
958
949
query . literalSearch = false ;
959
950
foundStopChar = true ;
960
951
continue ;
961
- } else if ( isWhitespace ( c ) ) {
952
+ } else if ( c === " " ) {
962
953
skipWhitespace ( parserState ) ;
963
954
continue ;
964
955
}
@@ -1118,7 +1109,7 @@ function initSearch(rawSearchIndex) {
1118
1109
}
1119
1110
}
1120
1111
}
1121
- userQuery = userQuery . trim ( ) ;
1112
+ userQuery = userQuery . trim ( ) . replace ( / \r | \n | \t / g , " " ) ;
1122
1113
const parserState = {
1123
1114
length : userQuery . length ,
1124
1115
pos : 0 ,
0 commit comments