mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Relax semantic of leading/trailing pipes in filter expressions in logger
This commit is contained in:
parent
79905aa798
commit
2e7654d429
1 changed files with 5 additions and 3 deletions
|
|
@ -1448,14 +1448,16 @@ const rowFilterer = (function() {
|
|||
if ( hardEnd ) {
|
||||
rawPart = rawPart.slice(0, -1);
|
||||
}
|
||||
if ( rawPart === '' ) { continue; }
|
||||
// https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions
|
||||
reStr = rawPart.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
// https://github.com/orgs/uBlockOrigin/teams/ublock-issues-volunteers/discussions/51
|
||||
// Be more flexible when interpreting leading/trailing pipes,
|
||||
// as leading/trailing pipes are often used in static filters.
|
||||
if ( hardBeg ) {
|
||||
reStr = '(?:^|\\s)' + reStr;
|
||||
reStr = reStr !== '' ? '(?:^|\\s|\\|)' + reStr : '\\|';
|
||||
}
|
||||
if ( hardEnd ) {
|
||||
reStr += '(?:\\s|$)';
|
||||
reStr += '(?:\\||\\s|$)';
|
||||
}
|
||||
}
|
||||
reStrs.push(reStr);
|
||||
|
|
|
|||
Loading…
Reference in a new issue