Skip to content

Commit

Permalink
Do not require end-users to have npm@2 (#80)
Browse files Browse the repository at this point in the history
* Do not require end-users to have `npm@2`

* Use xvfb-run and test on more recent Node platforms

* Update tests (.eu has changed)

* Embed updated rules

* Do not try to build `node@7`

* Revert to `[email protected]`

refs alex-seville/blanket#554
  • Loading branch information
Thomas Parisot authored Sep 13, 2016
1 parent 9f399cf commit 426814e
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 112 deletions.
15 changes: 2 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,19 @@ language: "node_js"
node_js:
- "0.10"
- "0.12"
- "iojs-1"
- "iojs-2"
- "iojs-3"
- "v4"
- "v5"
- "v6"

sudo: false

cache:
directories:
- node_modules

notifications:
email:
on_failure: change

before_install:
- npm install -g npm

before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3

script:
- npm test
- xvfb-run -a npm test
- npm run test-coverage
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"url": "https://github.com/oncletom/tld.js/issues"
},
"engines": {
"node": ">= 0.10",
"npm": ">= 2.13.0"
"node": ">= 0.10"
},
"main": "index.js",
"license": "MIT",
Expand All @@ -23,12 +22,12 @@
"test": "mocha -R dot -r env-test",
"posttest": "npm run lint && npm run test-browser",
"test-coverage": "mocha -R travis-cov -r blanket -r env-test",
"coverage": "mocha -R html-cov -r blanket -r env-test > coverage.html",
"coverage": "npm run test-coverage -- > coverage.html",
"test-watch": "mocha -R dot -r env-test --watch",
"test-browser": "testling",
"build": "node ./bin/update.js",
"generate-changelog": "github-changes -o oncletom -r 'tld.js' -n ${npm_package_version} -a --only-pulls --use-commit-body",
"version": "npm test && npm run generate-changelog && git add CHANGELOG.md rules.json"
"generate-changelog": "github-changes -o oncletom -r 'tld.js' -n ${npm_package_version} --only-pulls --use-commit-body",
"version": "npm run generate-changelog && git add CHANGELOG.md rules.json"
},
"tldjs": {
"providers": {
Expand Down Expand Up @@ -59,7 +58,7 @@
"dependencies": {},
"devDependencies": {
"async": "^1.4.2",
"blanket": "^1.1.5",
"blanket": "1.1.9",
"env-test": "^1.0.0",
"expect.js": "^0.3.1",
"github-changes": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion rules.json

Large diffs are not rendered by default.

182 changes: 91 additions & 91 deletions test/publicsuffix.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,124 +15,124 @@ describe('PublicSuffix tests', function(){
};
});

it('should return NULL on NULL input', function(){
checkPublicSuffix(null, null);
it('null input.', function(){
checkPublicSuffix(null, null);
});

it('should deal with mixed case', function(){
checkPublicSuffix('COM', null);
checkPublicSuffix('example.COM', 'example.com');
checkPublicSuffix('WwW.example.COM', 'example.com');
it('Mixed case.', function(){
checkPublicSuffix('COM', null);
checkPublicSuffix('example.COM', 'example.com');
checkPublicSuffix('WwW.example.COM', 'example.com');
});

it('should return NULL with leading dots', function(){
checkPublicSuffix('.com', null);
checkPublicSuffix('.example', null);
checkPublicSuffix('.example.com', null);
checkPublicSuffix('.example.example', null);
it('Leading dot.', function(){
checkPublicSuffix('.com', null);
checkPublicSuffix('.example', null);
checkPublicSuffix('.example.com', null);
checkPublicSuffix('.example.example', null);
});

it('should return the TLD even if the gTLD is unknown', function(){
it('Unlisted TLD.', function(){
checkPublicSuffix('example', null);
checkPublicSuffix('example.example', 'example.example');
checkPublicSuffix('b.example.example', 'example.example');
checkPublicSuffix('a.b.example.example', 'example.example');
});

it.skip('should return NULL on non-Internet TLDs', function(){
checkPublicSuffix('local', null);
checkPublicSuffix('example.local', null);
checkPublicSuffix('b.example.local', null);
checkPublicSuffix('a.b.example.local', null);
it.skip('Listed, but non-Internet, TLD.', function(){
checkPublicSuffix('local', null);
checkPublicSuffix('example.local', null);
checkPublicSuffix('b.example.local', null);
checkPublicSuffix('a.b.example.local', null);
});

it('should return the TLD with only 1 rule', function(){
checkPublicSuffix('biz', null);
checkPublicSuffix('domain.biz', 'domain.biz');
checkPublicSuffix('b.domain.biz', 'domain.biz');
checkPublicSuffix('a.b.domain.biz', 'domain.biz');
it('TLD with only 1 rule.', function(){
checkPublicSuffix('biz', null);
checkPublicSuffix('domain.biz', 'domain.biz');
checkPublicSuffix('b.domain.biz', 'domain.biz');
checkPublicSuffix('a.b.domain.biz', 'domain.biz');
});

it('should return the TLD of two levels hostname', function(){
checkPublicSuffix('com', null);
checkPublicSuffix('example.com', 'example.com');
checkPublicSuffix('b.example.com', 'example.com');
checkPublicSuffix('a.b.example.com', 'example.com');
checkPublicSuffix('uk.com', null);
checkPublicSuffix('example.uk.com', 'example.uk.com');
checkPublicSuffix('b.example.uk.com', 'example.uk.com');
checkPublicSuffix('a.b.example.uk.com', 'example.uk.com');
checkPublicSuffix('test.ac', 'test.ac');
it('TLD with some 2-level rules.', function(){
checkPublicSuffix('com', null);
checkPublicSuffix('example.com', 'example.com');
checkPublicSuffix('b.example.com', 'example.com');
checkPublicSuffix('a.b.example.com', 'example.com');
checkPublicSuffix('uk.com', null);
checkPublicSuffix('example.uk.com', 'example.uk.com');
checkPublicSuffix('b.example.uk.com', 'example.uk.com');
checkPublicSuffix('a.b.example.uk.com', 'example.uk.com');
checkPublicSuffix('test.ac', 'test.ac');
});

it('should return the TLD with 1 (wildcard) rule', function(){
checkPublicSuffix('mm', null);
checkPublicSuffix('c.mm', null);
checkPublicSuffix('b.c.mm', 'b.c.mm');
checkPublicSuffix('a.b.c.mm', 'b.c.mm');
it('TLD with only 1 (wildcard) rule.', function(){
checkPublicSuffix('mm', null);
checkPublicSuffix('c.mm', null);
checkPublicSuffix('b.c.mm', 'b.c.mm');
checkPublicSuffix('a.b.c.mm', 'b.c.mm');
});

it('should handle complex TLD', function(){
checkPublicSuffix('jp', null);
checkPublicSuffix('test.jp', 'test.jp');
checkPublicSuffix('www.test.jp', 'test.jp');
checkPublicSuffix('ac.jp', null);
checkPublicSuffix('test.ac.jp', 'test.ac.jp');
checkPublicSuffix('www.test.ac.jp', 'test.ac.jp');
checkPublicSuffix('kyoto.jp', null);
checkPublicSuffix('test.kyoto.jp', 'test.kyoto.jp');
checkPublicSuffix('ide.kyoto.jp', null);
checkPublicSuffix('b.ide.kyoto.jp', 'b.ide.kyoto.jp');
checkPublicSuffix('a.b.ide.kyoto.jp', 'b.ide.kyoto.jp');
checkPublicSuffix('c.kobe.jp', null);
checkPublicSuffix('b.c.kobe.jp', 'b.c.kobe.jp');
checkPublicSuffix('a.b.c.kobe.jp', 'b.c.kobe.jp');
checkPublicSuffix('city.kobe.jp', 'city.kobe.jp');
checkPublicSuffix('www.city.kobe.jp', 'city.kobe.jp');
it('More complex TLD.', function(){
checkPublicSuffix('jp', null);
checkPublicSuffix('test.jp', 'test.jp');
checkPublicSuffix('www.test.jp', 'test.jp');
checkPublicSuffix('ac.jp', null);
checkPublicSuffix('test.ac.jp', 'test.ac.jp');
checkPublicSuffix('www.test.ac.jp', 'test.ac.jp');
checkPublicSuffix('kyoto.jp', null);
checkPublicSuffix('test.kyoto.jp', 'test.kyoto.jp');
checkPublicSuffix('ide.kyoto.jp', null);
checkPublicSuffix('b.ide.kyoto.jp', 'b.ide.kyoto.jp');
checkPublicSuffix('a.b.ide.kyoto.jp', 'b.ide.kyoto.jp');
checkPublicSuffix('c.kobe.jp', null);
checkPublicSuffix('b.c.kobe.jp', 'b.c.kobe.jp');
checkPublicSuffix('a.b.c.kobe.jp', 'b.c.kobe.jp');
checkPublicSuffix('city.kobe.jp', 'city.kobe.jp');
checkPublicSuffix('www.city.kobe.jp', 'city.kobe.jp');
});

it('should deal with complex combination of wildcard and exception', function(){
checkPublicSuffix('ck', null);
checkPublicSuffix('test.ck', null);
checkPublicSuffix('b.test.ck', 'b.test.ck');
checkPublicSuffix('a.b.test.ck', 'b.test.ck');
checkPublicSuffix('www.ck', 'www.ck');
checkPublicSuffix('www.www.ck', 'www.ck');
it('TLD with a wildcard rule and exceptions.', function(){
checkPublicSuffix('ck', null);
checkPublicSuffix('test.ck', null);
checkPublicSuffix('b.test.ck', 'b.test.ck');
checkPublicSuffix('a.b.test.ck', 'b.test.ck');
checkPublicSuffix('www.ck', 'www.ck');
checkPublicSuffix('www.www.ck', 'www.ck');
});

it('should deal with US K12 rules', function(){
checkPublicSuffix('us', null);
checkPublicSuffix('test.us', 'test.us');
checkPublicSuffix('www.test.us', 'test.us');
checkPublicSuffix('ak.us', null);
checkPublicSuffix('test.ak.us', 'test.ak.us');
checkPublicSuffix('www.test.ak.us', 'test.ak.us');
checkPublicSuffix('k12.ak.us', null);
checkPublicSuffix('test.k12.ak.us', 'test.k12.ak.us');
checkPublicSuffix('www.test.k12.ak.us', 'test.k12.ak.us');
it('US K12.', function(){
checkPublicSuffix('us', null);
checkPublicSuffix('test.us', 'test.us');
checkPublicSuffix('www.test.us', 'test.us');
checkPublicSuffix('ak.us', null);
checkPublicSuffix('test.ak.us', 'test.ak.us');
checkPublicSuffix('www.test.ak.us', 'test.ak.us');
checkPublicSuffix('k12.ak.us', null);
checkPublicSuffix('test.k12.ak.us', 'test.k12.ak.us');
checkPublicSuffix('www.test.k12.ak.us', 'test.k12.ak.us');
});

it('should deal with IDN labels', function(){
//checkPublicSuffix('食狮.com.cn', '食狮.com.cn');
//checkPublicSuffix('食狮.公司.cn', '食狮.公司.cn');
//checkPublicSuffix('www.食狮.公司.cn', '食狮.公司.cn');
//checkPublicSuffix('shishi.公司.cn', 'shishi.公司.cn');
//checkPublicSuffix('公司.cn', null);
//checkPublicSuffix('食狮.中国', '食狮.中国');
//checkPublicSuffix('www.食狮.中国', '食狮.中国');
//checkPublicSuffix('shishi.中国', 'shishi.中国');
//checkPublicSuffix('中国', null);
it('IDN labels.', function(){
// checkPublicSuffix('食狮.com.cn', '食狮.com.cn');
// checkPublicSuffix('食狮.公司.cn', '食狮.公司.cn');
// checkPublicSuffix('www.食狮.公司.cn', '食狮.公司.cn');
// checkPublicSuffix('shishi.公司.cn', 'shishi.公司.cn');
// checkPublicSuffix('公司.cn', null);
// checkPublicSuffix('食狮.中国', '食狮.中国');
// checkPublicSuffix('www.食狮.中国', '食狮.中国');
// checkPublicSuffix('shishi.中国', 'shishi.中国');
// checkPublicSuffix('中国', null);
});

it('should deal with punycodes IDN labels', function(){
checkPublicSuffix('xn--85x722f.com.cn', 'xn--85x722f.com.cn');
checkPublicSuffix('xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn');
checkPublicSuffix('www.xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn');
checkPublicSuffix('shishi.xn--55qx5d.cn', 'shishi.xn--55qx5d.cn');
checkPublicSuffix('xn--55qx5d.cn', null);
checkPublicSuffix('xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s');
checkPublicSuffix('www.xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s');
checkPublicSuffix('shishi.xn--fiqs8s', 'shishi.xn--fiqs8s');
checkPublicSuffix('xn--fiqs8s', null);
it('Same as above, but punycoded.', function(){
checkPublicSuffix('xn--85x722f.com.cn', 'xn--85x722f.com.cn');
checkPublicSuffix('xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn');
checkPublicSuffix('www.xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn');
checkPublicSuffix('shishi.xn--55qx5d.cn', 'shishi.xn--55qx5d.cn');
checkPublicSuffix('xn--55qx5d.cn', null);
checkPublicSuffix('xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s');
checkPublicSuffix('www.xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s');
checkPublicSuffix('shishi.xn--fiqs8s', 'shishi.xn--fiqs8s');
checkPublicSuffix('xn--fiqs8s', null);
});
});
2 changes: 1 addition & 1 deletion test/tld.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('tld.js', function () {
});

it('should return the suffix if a rule exists that has no exceptions', function(){
expect(tld.rules.eu).to.be('');
expect(tld.rules.eu).to.be('mycd');
expect(tld.getPublicSuffix('microsoft.eu')).to.be('eu');
});

Expand Down

0 comments on commit 426814e

Please sign in to comment.