Skip to content

Commit

Permalink
#169 Completely replaced list.json by list.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
nalgeon committed Mar 27, 2019
1 parent d729e44 commit c361efc
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 73 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

[![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/francois-guillaume-ribreau?utm_source=github&utm_medium=button&utm_term=francois-guillaume-ribreau&utm_campaign=github) [![available-for-advisory](https://img.shields.io/badge/available%20for%20advising-yes-ff69b4.svg?)](http://bit.ly/2c7uFJq) ![extra](https://img.shields.io/badge/actively%20maintained-yes-ff69b4.svg?)

Cross-language email validation. Backed by a [database](./list.json) of **5277 throwable email providers**.
Cross-language email validation. Backed by a [database](./list.txt) of **over 19000 throwable email domains**.

* Validate the format of your email (uses [validator.js](https://github.com/chriso/validator.js/blob/master/validator.js#L38) email regex underneath and `FILTER_VALIDATE_EMAIL` for PHP)
* Validate if the email is not a **temporary mail** (yopmail-like..., [add your own dataset to list.json](./list.json))
* Validate if the email is not a **temporary mail** (yopmail-like..., [add your own dataset to list.txt](./list.txt))

This will be very helpful when you have to contact your users and you want to avoid errors causing lack of communication or want to block "spamboxes".

Expand Down Expand Up @@ -223,9 +223,9 @@ __We accept pull-requests for other package manager__.
Array.prototype.slice.call(document.querySelectorAll('.entry > ul > li a')).map(function(el){return el.innerText});
```

... [please add your own dataset to list.json](./list.json).
... [please add your own dataset to list.txt](./list.txt).

Regenerate libraries from list.json
Regenerate libraries from list.txt
-------------------------------

Just run (requires NodeJS):
Expand Down
22 changes: 0 additions & 22 deletions lib/converter.js

This file was deleted.

12 changes: 8 additions & 4 deletions lib/loader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var cjson = require('cjson');
var fs = require('fs');
var p = require('path');
var _ = require('lodash');

Expand All @@ -10,11 +10,15 @@ var _ = require('lodash');
*/
var loader = {
getList: function () {
return _.flowRight(_.flatten, _.uniq)(this.getLists());
var path = p.resolve(__dirname, '../list.txt');
return _.uniq(this.getDomains(path));
},

getLists: function () {
return cjson.load(p.resolve(__dirname, '../list.json'));
getDomains: function (path) {
return fs
.readFileSync(path)
.toString()
.split('\n');
}
};

Expand Down
1 change: 0 additions & 1 deletion list.json

This file was deleted.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Cross-language temporary (disposable/throwaway) email detection library. Covers hundreds fake email providers.",
"main": "platform/node/",
"scripts": {
"build": "node plain2json.js && node gen.js",
"build": "node gen.js",
"setup": "npm run build && npm-run-all --max-parallel 2 --parallel setup:*",
"setup:ruby": "docker run -i -v $(pwd):/app -w /app centurylink/ruby-base:2.2 bundler",
"setup:clojure": "docker run -i -v $(pwd):/app -w /app clojure:lein-2.8.1 lein install",
Expand Down Expand Up @@ -124,7 +124,6 @@
"license": "MIT",
"dependencies": {
"async": "^2.6.0",
"cjson": "^0.5.0",
"eventemitter2": "^5.0.1",
"glob": "^7.0.3",
"lodash": ">4.17.5",
Expand All @@ -139,7 +138,6 @@
"npm-run-all": "^4.1.3",
"projectz": "^1.3.2",
"should": "^13.2.1",
"tmp": "^0.1.0",
"updtr": "^2.0.0"
},
"optionalDependencies": {},
Expand Down
7 changes: 0 additions & 7 deletions plain2json.js

This file was deleted.

22 changes: 0 additions & 22 deletions test/converter.test.js

This file was deleted.

16 changes: 6 additions & 10 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ suite('Loader', function () {
loader = require('../lib/loader');
});

suite('#getLists', function () {
test('should return an array', function () {
t.ok(_.isArray(loader.getLists()));
});

test('should return an array of array', function () {
loader.getLists().forEach(function (v, i) {
t.ok(_.isArray(v), "index " + i);
});
suite('#getDomains', function () {
test('should load domains from plain text file', function () {
domains = loader.getDomains('test/list.test.txt');
expected = ['one.com', 'two.org', 'three.net'];
domains.toString().should.equal(expected.toString());
});
});

Expand All @@ -26,7 +22,7 @@ suite('Loader', function () {

test('should return an array of string', function () {
loader.getList().forEach(function (v, i) {
t.ok(_.isString(v), "index " + i);
t.ok(_.isString(v), 'index ' + i);
});
});
});
Expand Down

0 comments on commit c361efc

Please sign in to comment.