mirror of https://github.com/gorhill/uBlock.git
minor code review
This commit is contained in:
parent
ef84e6d8fd
commit
14109b33d6
|
@ -98,20 +98,20 @@ var fromNetFilter = function(details) {
|
||||||
var fromCosmeticFilter = function(details) {
|
var fromCosmeticFilter = function(details) {
|
||||||
var match = /^#@?#/.exec(details.rawFilter),
|
var match = /^#@?#/.exec(details.rawFilter),
|
||||||
prefix = match[0],
|
prefix = match[0],
|
||||||
filter = details.rawFilter.slice(prefix.length),
|
needle = details.rawFilter.slice(prefix.length),
|
||||||
selector = filter;
|
selector = needle;
|
||||||
|
|
||||||
// With low generic simple cosmetic filters, the class or id prefix
|
// With low generic simple cosmetic filters, the class or id prefix
|
||||||
// character is not part of the compiled data. So we must be ready to
|
// character is not part of the compiled data. So we must be ready to
|
||||||
// look-up version of the selector without the prefix character.
|
// look-up version of the selector without the prefix character.
|
||||||
var idOrClassPrefix = filter.charAt(0),
|
var idOrClassPrefix = needle.charAt(0),
|
||||||
cssPrefixMatcher;
|
cssPrefixMatcher;
|
||||||
if ( idOrClassPrefix === '#' ) {
|
if ( idOrClassPrefix === '#' ) {
|
||||||
cssPrefixMatcher = '#?';
|
cssPrefixMatcher = '#?';
|
||||||
filter = filter.slice(1);
|
needle = needle.slice(1);
|
||||||
} else if ( idOrClassPrefix === '.' ) {
|
} else if ( idOrClassPrefix === '.' ) {
|
||||||
cssPrefixMatcher = '\\.?';
|
cssPrefixMatcher = '\\.?';
|
||||||
filter = filter.slice(1);
|
needle = needle.slice(1);
|
||||||
} else {
|
} else {
|
||||||
idOrClassPrefix = '';
|
idOrClassPrefix = '';
|
||||||
cssPrefixMatcher = '';
|
cssPrefixMatcher = '';
|
||||||
|
@ -122,7 +122,7 @@ var fromCosmeticFilter = function(details) {
|
||||||
var reFilter = new RegExp(
|
var reFilter = new RegExp(
|
||||||
'^\\[\\d,[^\\n]*\\\\*"' +
|
'^\\[\\d,[^\\n]*\\\\*"' +
|
||||||
cssPrefixMatcher +
|
cssPrefixMatcher +
|
||||||
reEscapeCosmetic(filter) +
|
reEscapeCosmetic(needle) +
|
||||||
'\\\\*"[^\\n]*\\]$',
|
'\\\\*"[^\\n]*\\]$',
|
||||||
'gm'
|
'gm'
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue