mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Make logger console filter expression case-insensitive
This commit is contained in:
parent
ee67cd6284
commit
3e7eca364b
@ -77,6 +77,8 @@ const dispatchTabidChange = vAPI.defer.create(( ) => {
|
|||||||
document.dispatchEvent(new Event('tabIdChanged'));
|
document.dispatchEvent(new Event('tabIdChanged'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const escapeRegexStr = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@ -161,7 +163,7 @@ const regexFromURLFilteringResult = function(result) {
|
|||||||
if ( url === '*' ) {
|
if ( url === '*' ) {
|
||||||
return new RegExp('^.*$', 'gi');
|
return new RegExp('^.*$', 'gi');
|
||||||
}
|
}
|
||||||
return new RegExp('^' + url.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gi');
|
return new RegExp('^' + escapeRegexStr(url), 'gi');
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -174,7 +176,7 @@ const nodeFromURL = function(parent, url, re, type) {
|
|||||||
fragment.textContent = url;
|
fragment.textContent = url;
|
||||||
} else {
|
} else {
|
||||||
if ( typeof re === 'string' ) {
|
if ( typeof re === 'string' ) {
|
||||||
re = new RegExp(re.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g');
|
re = new RegExp(escapeRegexStr(re), 'g');
|
||||||
}
|
}
|
||||||
const matches = re.exec(url);
|
const matches = re.exec(url);
|
||||||
if ( matches === null || matches[0].length === 0 ) {
|
if ( matches === null || matches[0].length === 0 ) {
|
||||||
@ -2008,13 +2010,16 @@ const consolePane = (( ) => {
|
|||||||
|
|
||||||
const filterExprFromInput = ( ) => {
|
const filterExprFromInput = ( ) => {
|
||||||
const raw = qs$('#infoInspector .permatoolbar input').value.trim();
|
const raw = qs$('#infoInspector .permatoolbar input').value.trim();
|
||||||
if ( raw.startsWith('-') ) {
|
if ( raw.startsWith('-') && raw.length > 1 ) {
|
||||||
filterExpr.pattern = raw.slice(1);
|
filterExpr.pattern = raw.slice(1);
|
||||||
filterExpr.not = true;
|
filterExpr.not = true;
|
||||||
} else {
|
} else {
|
||||||
filterExpr.pattern = raw;
|
filterExpr.pattern = raw;
|
||||||
filterExpr.not = false;
|
filterExpr.not = false;
|
||||||
}
|
}
|
||||||
|
if ( filterExpr.pattern !== '' ) {
|
||||||
|
filterExpr.pattern = new RegExp(escapeRegexStr(filterExpr.pattern), 'i');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const addRows = ( ) => {
|
const addRows = ( ) => {
|
||||||
@ -2029,8 +2034,8 @@ const consolePane = (( ) => {
|
|||||||
if ( entry.voided ) { continue; }
|
if ( entry.voided ) { continue; }
|
||||||
const fields = entry.textContent.split('\x1F').slice(0, 2);
|
const fields = entry.textContent.split('\x1F').slice(0, 2);
|
||||||
const textContent = fields.join('\xA0');
|
const textContent = fields.join('\xA0');
|
||||||
if ( pattern !== '' ) {
|
if ( pattern instanceof RegExp ) {
|
||||||
if ( textContent.includes(pattern) === not ) { continue; }
|
if ( pattern.test(textContent) === not ) { continue; }
|
||||||
}
|
}
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.dataset.id = `${entry.id}`;
|
div.dataset.id = `${entry.id}`;
|
||||||
@ -2165,7 +2170,7 @@ const rowFilterer = (( ) => {
|
|||||||
rawPart = rawPart.slice(0, -1);
|
rawPart = rawPart.slice(0, -1);
|
||||||
}
|
}
|
||||||
// https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions
|
// https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions
|
||||||
reStr = rawPart.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
reStr = escapeRegexStr(rawPart);
|
||||||
// https://github.com/orgs/uBlockOrigin/teams/ublock-issues-volunteers/discussions/51
|
// https://github.com/orgs/uBlockOrigin/teams/ublock-issues-volunteers/discussions/51
|
||||||
// Be more flexible when interpreting leading/trailing pipes,
|
// Be more flexible when interpreting leading/trailing pipes,
|
||||||
// as leading/trailing pipes are often used in static filters.
|
// as leading/trailing pipes are often used in static filters.
|
||||||
|
Loading…
Reference in New Issue
Block a user