mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 03:12:33 +01:00
Code review of https://github.com/gorhill/uBlock/commit/f930da7ad64a
This commit is contained in:
parent
f930da7ad6
commit
9693d07a6d
@ -171,22 +171,23 @@
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const normalizeRawToken = function(raw) {
|
const normalizeRawFilter = function(rawFilter) {
|
||||||
let rawEnd = raw.length;
|
let rawToken = rawFilter.slice(4, -1);
|
||||||
let end = raw.indexOf(',');
|
let rawEnd = rawToken.length;
|
||||||
|
let end = rawToken.indexOf(',');
|
||||||
if ( end === -1 ) {
|
if ( end === -1 ) {
|
||||||
end = rawEnd;
|
end = rawEnd;
|
||||||
}
|
}
|
||||||
let token = raw.slice(0, end).trim();
|
let token = rawToken.slice(0, end).trim();
|
||||||
let normalized = token.endsWith('.js') ? token.slice(0, -3) : token;
|
let normalized = token.endsWith('.js') ? token.slice(0, -3) : token;
|
||||||
let beg = end + 1;
|
let beg = end + 1;
|
||||||
while ( beg < rawEnd ) {
|
while ( beg < rawEnd ) {
|
||||||
end = raw.indexOf(',', beg);
|
end = rawToken.indexOf(',', beg);
|
||||||
if ( end === -1 ) { end = rawEnd; }
|
if ( end === -1 ) { end = rawEnd; }
|
||||||
normalized += ', ' + raw.slice(beg, end).trim();
|
normalized += ', ' + rawToken.slice(beg, end).trim();
|
||||||
beg = end + 1;
|
beg = end + 1;
|
||||||
}
|
}
|
||||||
return normalized;
|
return `+js(${normalized})`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const lookupScriptlet = function(rawToken, reng, toInject) {
|
const lookupScriptlet = function(rawToken, reng, toInject) {
|
||||||
@ -270,7 +271,7 @@
|
|||||||
writer.select(1001);
|
writer.select(1001);
|
||||||
|
|
||||||
// Only exception filters are allowed to be global.
|
// Only exception filters are allowed to be global.
|
||||||
const normalized = normalizeRawToken(parsed.suffix);
|
const normalized = normalizeRawFilter(parsed.suffix);
|
||||||
|
|
||||||
if ( parsed.hostnames.length === 0 ) {
|
if ( parsed.hostnames.length === 0 ) {
|
||||||
if ( parsed.exception ) {
|
if ( parsed.exception ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user