Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/url.js

Issue 30009560: Noissue - Rename lib/domain.js to lib/url.js (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Feb. 16, 2019, 12:42 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/url.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/url.js
===================================================================
rename from test/domain.js
rename to test/url.js
--- a/test/domain.js
+++ b/test/url.js
@@ -20,28 +20,28 @@
// Only starting NodeJS 10 that URL is in the global space.
const {URL} = require("url");
const {createSandbox} = require("./_common");
const publicSuffixes = require("../data/publicSuffixList.json");
let normalizeHostname = null;
let isThirdParty = null;
-let getDomain = null;
+let getBaseDomain = null;
exports.setUp = function(callback)
{
let sandboxedRequire = createSandbox({
extraExports: {
- domain: ["getDomain"]
+ domain: ["getBaseDomain"]
}
});
(
{normalizeHostname, isThirdParty,
- getDomain} = sandboxedRequire("../lib/domain")
+ getBaseDomain} = sandboxedRequire("../lib/url")
);
callback();
};
function hostnameToURL(hostname)
{
return new URL("http://" + hostname);
@@ -172,40 +172,43 @@
for (let i = 0; i < offset + levels; i++)
{
let hostname = parts.slice(0, i).join(".");
hostname += (hostname ? "." : "") + suffix;
let expected = parts.slice(Math.max(0, i - offset), i).join(".");
expected += (expected ? "." : "") + suffix;
- test.equal(getDomain(hostname), expected,
- `getDomain("${hostname}") == "${expected}"` +
+ test.equal(getBaseDomain(hostname), expected,
+ `getBaseDomain("${hostname}") == "${expected}"` +
` with {suffix: "${suffix}", offset: ${offset}}`);
}
}
// Unknown suffixes.
test.equal(typeof publicSuffixes["localhost"], "undefined");
test.equal(typeof publicSuffixes["localhost.localdomain"], "undefined");
- test.equal(getDomain("localhost"), "localhost");
- test.equal(getDomain("localhost.localdomain"), "localhost.localdomain");
- test.equal(getDomain("mail.localhost.localdomain"), "localhost.localdomain");
- test.equal(getDomain("www.example.localhost.localdomain"),
+ test.equal(getBaseDomain("localhost"), "localhost");
+ test.equal(getBaseDomain("localhost.localdomain"), "localhost.localdomain");
+ test.equal(
+ getBaseDomain("mail.localhost.localdomain"),
+ "localhost.localdomain"
+ );
+ test.equal(getBaseDomain("www.example.localhost.localdomain"),
"localhost.localdomain");
// Unknown suffixes that overlap partly with known suffixes.
test.equal(typeof publicSuffixes["example.com"], "undefined");
test.equal(typeof publicSuffixes["africa.com"], "number");
test.equal(typeof publicSuffixes["compute.amazonaws.com"], "number");
- test.equal(getDomain("example.com"), "example.com");
- test.equal(getDomain("mail.example.com"), "example.com");
- test.equal(getDomain("secure.mail.example.com"), "example.com");
+ test.equal(getBaseDomain("example.com"), "example.com");
+ test.equal(getBaseDomain("mail.example.com"), "example.com");
+ test.equal(getBaseDomain("secure.mail.example.com"), "example.com");
// Cascading offsets.
// If these sanity checks fail, look for other examles of cascading offsets
// from the public suffix list.
test.equal(
typeof publicSuffixes[
"images.example.s3.dualstack.us-east-1.amazonaws.com"
@@ -220,27 +223,32 @@
test.equal(typeof publicSuffixes["dualstack.us-east-1.amazonaws.com"],
"undefined");
test.equal(typeof publicSuffixes["example.us-east-1.amazonaws.com"],
"undefined");
test.equal(publicSuffixes["us-east-1.amazonaws.com"], 1);
test.equal(typeof publicSuffixes["example.amazonaws.com"], "undefined");
test.equal(typeof publicSuffixes["amazonaws.com"], "undefined");
- test.equal(getDomain("images.example.s3.dualstack.us-east-1.amazonaws.com"),
+ test.equal(
+ getBaseDomain("images.example.s3.dualstack.us-east-1.amazonaws.com"),
+ "example.s3.dualstack.us-east-1.amazonaws.com"
+ );
+ test.equal(getBaseDomain("example.s3.dualstack.us-east-1.amazonaws.com"),
"example.s3.dualstack.us-east-1.amazonaws.com");
- test.equal(getDomain("example.s3.dualstack.us-east-1.amazonaws.com"),
- "example.s3.dualstack.us-east-1.amazonaws.com");
- test.equal(getDomain("s3.dualstack.us-east-1.amazonaws.com"),
+ test.equal(getBaseDomain("s3.dualstack.us-east-1.amazonaws.com"),
"s3.dualstack.us-east-1.amazonaws.com");
- test.equal(getDomain("dualstack.us-east-1.amazonaws.com"),
+ test.equal(getBaseDomain("dualstack.us-east-1.amazonaws.com"),
"dualstack.us-east-1.amazonaws.com");
- test.equal(getDomain("example.us-east-1.amazonaws.com"),
+ test.equal(getBaseDomain("example.us-east-1.amazonaws.com"),
"example.us-east-1.amazonaws.com");
- test.equal(getDomain("us-east-1.amazonaws.com"), "us-east-1.amazonaws.com");
- test.equal(getDomain("example.amazonaws.com"), "amazonaws.com");
- test.equal(getDomain("amazonaws.com"), "amazonaws.com");
+ test.equal(
+ getBaseDomain("us-east-1.amazonaws.com"),
+ "us-east-1.amazonaws.com"
+ );
+ test.equal(getBaseDomain("example.amazonaws.com"), "amazonaws.com");
+ test.equal(getBaseDomain("amazonaws.com"), "amazonaws.com");
// Edge case.
- test.equal(getDomain(""), "");
+ test.equal(getBaseDomain(""), "");
test.done();
};
« no previous file with comments | « lib/url.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld