-
Notifications
You must be signed in to change notification settings - Fork 45
/
test-psl.js
30 lines (25 loc) · 943 Bytes
/
test-psl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const test = require("tape");
const psl = require("./psl");
test("Malformed hostname", function(assert) {
assert.equal(psl.getDomain("....."), undefined);
assert.equal(psl.getDomain("127.0.0.1"), undefined);
assert.equal(psl.getDomain("foo"), undefined);
assert.end();
});
test("Normal rules", function(assert) {
assert.equal(psl.getDomain("com"), undefined);
assert.equal(psl.getDomain("foo.com"), "foo.com");
assert.equal(psl.getDomain("foo.bar.com"), "bar.com");
assert.end();
});
test("Exception rules", function(assert) {
assert.equal(psl.getDomain("foo.ck"), undefined);
assert.equal(psl.getDomain("www.ck"), "www.ck");
assert.equal(psl.getDomain("foo.www.ck"), "www.ck");
assert.end();
});
test("Wildcard rules", function(assert) {
assert.equal(psl.getDomain("foobar.foo.bar.ck"), "foo.bar.ck");
assert.equal(psl.getDomain("foo.bar.ck"), "foo.bar.ck");
assert.end();
});