Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser feature #31

Merged
merged 11 commits into from
Oct 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
"boss": true,
"eqnull": true,
"node": true,
"strict": true,
"es5": true
"strict": true
}
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
language: "node_js"
node_js:
- 0.8
- 0.10
- "0.8"
- "0.10"
notifications:
email:
on_success: change
on_failure: change
before_install:
- npm install -g grunt-cli --production
before_script:
- npm run-script build
- npm run build
23 changes: 3 additions & 20 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,10 @@

module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
jshint: {
all: ['grunt.js', 'lib/**/*.js', 'test/**/*.js'],
options: {
jshintrc: '.jshintrc'
}
},
watch: {
files: '<config:lint.files>',
tasks: 'lint'
}
});
grunt.initConfig({});

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('default', 'jshint');
grunt.registerTask('default', []);

// Custom Task to build files
grunt.registerTask('update',
'Update ruleset from publicsuffix.org dataset.',
require(__dirname + '/lib/grunt/update.js')(grunt)
);
grunt.loadTasks('lib/grunt');
};
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ tld.js
======

[![Build Status](https://secure.travis-ci.org/oncletom/tld.js.png?branch=master)](http://travis-ci.org/oncletom/tld.js)
[![browser support](https://ci.testling.com/oncletom/tld.js.png)](https://ci.testling.com/oncletom/tld.js)

Handful API to do stuff with domain names and URIs: validity, public etc.

Expand Down
1 change: 1 addition & 0 deletions dist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
File renamed without changes.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

var tld = require('./lib/tld.js').init();
tld.rules = require('./src/rules.json');
tld.rules = require('./dist/rules.json');

module.exports = tld;
9 changes: 3 additions & 6 deletions lib/grunt/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ module.exports = function(grunt){
return provider && config.providers[provider] ? provider : defaultProvider;
}

/**
* @param {string|undefined} provider
*/
return function tldUpdate(provider){
grunt.registerTask('update', function tldUpdate(provider){
var done, config;

done = this.async();
Expand All @@ -56,13 +53,13 @@ module.exports = function(grunt){

data = JSON.stringify(data);

grunt.file.write(__dirname + '/../../src/'+filename, data);
grunt.file.write('dist/'+filename, data);

callback();
}, 5);

queue.drain = done;
queue.push(require(__dirname + '/../exports/index.js'));
});
};
});
};
2 changes: 1 addition & 1 deletion lib/tld.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

var Rule = require(__dirname + '/rule.js');
var Rule = require('./rule.js');

/**
* tld library
Expand Down
33 changes: 28 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,50 @@
},
"main": "index.js",
"scripts": {
"test": "./node_modules/.bin/mocha --ui tdd",
"build": "grunt update",
"prepublish": "grunt update"
"test": "npm run lint && npm run test-node",
"lint": "jshint --config .jshintrc lib/**/*.js",
"test-node": "mocha --ui tdd --reporter dot",
"test-browser": "testling",
"build": "npm run build-rules && npm run build-browser",
"build-rules": "grunt update",
"build-browser": "browserify -r ./lib/tld.js > dist/tld.js"
},
"engines": {
"node": "0.8.x || 0.10.x"
},
"testling": {
"browsers": [
"ie6",
"ie7",
"ie8",
"ie9",
"firefox/15",
"chrome/22",
"opera/12",
"safari/5.1"
],
"harness": "mocha-tdd",
"files": "test/*.js"
},
"dependencies": {},
"devDependencies": {
"request": "~2.12.0",
"grunt": "~0.4.1",
"mocha": "~1.7.4",
"mocha": "~1.13.0",
"expect.js": "~0.2.0",
"grunt-contrib-watch": "~0.3.1",
"grunt-contrib-jshint": "~0.4.3"
"grunt-contrib-jshint": "~0.4.3",
"testling": "~1.5.1",
"browserify": "~2.34.0",
"grunt-cli": "~0.1.9",
"jshint": "~2.1.11"
},
"keywords": [
"tld",
"sld",
"domain",
"travis",
"browser",
"uri",
"url",
"domain name",
Expand Down
1 change: 0 additions & 1 deletion src/.gitignore

This file was deleted.

12 changes: 6 additions & 6 deletions test/publicsuffix.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ suite('http://publicsuffix.org/list/test.txt', function(){
});

test('TLD with a wildcard rule and exceptions', function(){
checkPublicSuffix('om', null);
checkPublicSuffix('test.om', null);
checkPublicSuffix('b.test.om', 'b.test.om');
checkPublicSuffix('a.b.test.om', 'b.test.om');
checkPublicSuffix('songfest.om', 'songfest.om');
checkPublicSuffix('www.songfest.om', 'songfest.om');
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');
});

test('US K12', function(){
Expand Down
2 changes: 1 addition & 1 deletion test/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* global suite, test, suiteSetup */

var Rule = require(__dirname + '/../lib/rule.js');
var Rule = require('../lib/rule.js');
var expect = require('expect.js');

suite('Public Suffix Rule', function () {
Expand Down