1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01:00

code review

This commit is contained in:
gorhill 2015-11-23 09:49:50 -05:00
parent 2aadc2a969
commit 30039ff9c7
4 changed files with 16 additions and 22 deletions

View File

@ -429,7 +429,10 @@ var getRepoMetadata = function(callback) {
) {
entry.repoChecksum = entry.localChecksum;
}
// New entry in remote repo.
if ( entry.repoChecksum !== '' || entry.localChecksum === '' ) {
entry.localChecksum = 'd41d8cd98f00b204e9800998ecf8427e';
checksumsChanged = true;
continue;
}
checksumsChanged = true;

View File

@ -95,17 +95,14 @@ var isIPAddress = function(hostname) {
/******************************************************************************/
var toBroaderHostname = function(hostname) {
if ( hostname === '*' ) {
return '';
}
if ( isIPAddress(hostname) ) {
return '*';
}
var pos = hostname.indexOf('.');
if ( pos === -1 ) {
return '*';
if ( pos !== -1 ) {
return hostname.slice(pos + 1);
}
return hostname.slice(pos + 1);
return hostname !== '*' && hostname !== '' ? '*' : '';
};
Matrix.toBroaderHostname = toBroaderHostname;

View File

@ -86,17 +86,14 @@ var isIPAddress = function(hostname) {
/******************************************************************************/
var toBroaderHostname = function(hostname) {
if ( hostname === '*' ) {
return '';
}
if ( isIPAddress(hostname) ) {
return '*';
}
var pos = hostname.indexOf('.');
if ( pos === -1 ) {
return '*';
if ( pos !== -1 ) {
return hostname.slice(pos + 1);
}
return hostname.slice(pos + 1);
return hostname !== '*' && hostname !== '' ? '*' : '';
};
HnSwitches.toBroaderHostname = toBroaderHostname;

View File

@ -30,14 +30,11 @@
/******************************************************************************/
var toBroaderHostname = function(hostname) {
if ( hostname === '*' ) {
return '';
}
var pos = hostname.indexOf('.');
if ( pos === -1 ) {
return '*';
if ( pos !== -1 ) {
return hostname.slice(pos + 1);
}
return hostname.slice(pos + 1);
return hostname !== '*' && hostname !== '' ? '*' : '';
};
/******************************************************************************/
@ -79,10 +76,10 @@ RedirectEngine.prototype.lookup = function(context) {
}
}
}
}
src = toBroaderHostname(src);
if ( src === '' ) {
break;
src = toBroaderHostname(src);
if ( src === '' ) {
break;
}
}
}
des = toBroaderHostname(des);