1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

Append wildcard character only when filter starts & ends with /

Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/1088
This commit is contained in:
Raymond Hill 2024-03-14 13:32:36 -04:00
parent 65b6753c69
commit 1cb190e102
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1341,9 +1341,7 @@ dom.on(document, 'keydown', ev => {
if ( reSchemeOnly.test(value) ) { if ( reSchemeOnly.test(value) ) {
value = `|${value}`; value = `|${value}`;
} else { } else {
if ( value.endsWith('/') ) { if ( /[/?]/.test(value) === false ) {
value += '*';
} else if ( /[/?]/.test(value) === false ) {
value += '^'; value += '^';
} }
value = `||${value}`; value = `||${value}`;
@ -1415,7 +1413,8 @@ dom.on(document, 'keydown', ev => {
// Create static filter // Create static filter
if ( target.id === 'createStaticFilter' ) { if ( target.id === 'createStaticFilter' ) {
ev.stopPropagation(); ev.stopPropagation();
const value = staticFilterNode().value; const value = staticFilterNode().value
.replace(/^((?:@@)?\/.+\/)(\$|$)/, '$1*$2');
// Avoid duplicates // Avoid duplicates
if ( createdStaticFilters.hasOwnProperty(value) ) { return; } if ( createdStaticFilters.hasOwnProperty(value) ) { return; }
createdStaticFilters[value] = true; createdStaticFilters[value] = true;