Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
naming according to what URI.js taught me
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Oct 19, 2013
1 parent a140c6c commit dafeb07
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions js/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function evaluate(type, domain) {
if ( httpsb.whitelist[key] ) {
return httpsb.ALLOWED_INDIRECT;
}
ancestor = getParentDomainFromDomain(ancestor);
ancestor = getParentHostnameFromHostname(ancestor);
}
// indirect: specific type, any domain
key = type + '/*';
Expand Down Expand Up @@ -219,7 +219,7 @@ function evaluate(type, domain) {
if ( httpsb.whitelist[key] ) {
return httpsb.ALLOWED_INDIRECT;
}
ancestor = getParentDomainFromDomain(ancestor);
ancestor = getParentHostnameFromHostname(ancestor);
}
// indirect: any type, any domain
if ( httpsb.whitelist['*/*'] ) {
Expand Down
8 changes: 4 additions & 4 deletions js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var initMatrixStats = function(pageStats) {
if ( !matrixStats[parent] ) {
matrixStats[parent] = new DomainStats();
}
parent = background.getParentDomainFromDomain(parent);
parent = background.getParentHostnameFromHostname(parent);
}
matrixStats[domain][type].count += 1;
// Issue #12: Count requests for whole row.
Expand Down Expand Up @@ -178,7 +178,7 @@ var getGroupStats = function() {
if ( dark ) {
break;
}
parent = background.getParentDomainFromDomain(parent);
parent = background.getParentHostnameFromHostname(parent);
}
// Domain of the page comes first
if ( background.getDomainFromHostname(domain) === pageDomain ) {
Expand All @@ -191,7 +191,7 @@ var getGroupStats = function() {
} else {
group = 2;
}
rootDomain = background.getTopMostDomainFromDomain(domain);
rootDomain = background.getDomainFromHostname(domain);
if ( !domainGroups[group][rootDomain] ) {
domainGroups[group][rootDomain] = { all: {}, directs: {} };
}
Expand Down Expand Up @@ -219,7 +219,7 @@ var getGroupStats = function() {
domain = domains[iDomain];
while ( domain ) {
group[rootDomain].all[domain] = group[rootDomain].directs[domain];
domain = background.getParentDomainFromDomain(domain);
domain = background.getParentHostnameFromHostname(domain);
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,34 +97,34 @@ function getUrlHrefRoot(url) {

// Return the parent domain. For IP address, there is no parent domain.

function getParentDomainFromDomain(domain) {
var cacherQuestion = 'getParentDomainFromDomain:' + domain;
function getParentHostnameFromHostname(hostname) {
var cacherQuestion = 'getParentHostnameFromHostname:' + hostname;
if ( Cacher.exists(cacherQuestion) ) {
return Cacher.response(cacherQuestion);
}
var uri = globalURI;
var subdomain = uri.hostname(domain).subdomain();
var subdomain = uri.hostname(hostname).subdomain();
if ( subdomain === '' ) {
return Cacher.remember(cacherQuestion, undefined);
}
var tld = uri.domain();
var domain = uri.domain();
var dot = subdomain.indexOf('.');
if ( dot < 0 ) {
return Cacher.remember(cacherQuestion, tld);
return Cacher.remember(cacherQuestion, domain);
}
return Cacher.remember(cacherQuestion, subdomain.slice(dot+1) + '.' + tld);
return Cacher.remember(cacherQuestion, subdomain.slice(dot+1) + '.' + domain);
}

/******************************************************************************/

// Return the top-most domain. For IP address, there is no parent domain.

function getTopMostDomainFromDomain(domain) {
var cacherQuestion = 'getTopMostDomainFromDomain:' + domain;
function getDomainFromHostname(hostname) {
var cacherQuestion = 'getDomainFromHostname:' + hostname;
if ( Cacher.exists(cacherQuestion) ) {
return Cacher.response(cacherQuestion);
}
return Cacher.remember(cacherQuestion, globalURI.hostname(domain).domain());
return Cacher.remember(cacherQuestion, globalURI.hostname(hostname).domain());
}

/******************************************************************************/
Expand Down

0 comments on commit dafeb07

Please sign in to comment.