mailchecker
Advanced tools
Comparing version 2.0.1 to 3.0.0
# Change Log | ||
## [Unreleased](https://github.com/fgribreau/mailchecker/tree/HEAD) | ||
## [v2.0.1](https://github.com/fgribreau/mailchecker/tree/v2.0.1) (2016-03-19) | ||
[Full Changelog](https://github.com/fgribreau/mailchecker/compare/v2.0.0...v2.0.1) | ||
[Full Changelog](https://github.com/fgribreau/mailchecker/compare/v2.0.0...HEAD) | ||
**Merged pull requests:** | ||
@@ -8,0 +7,0 @@ |
{ | ||
"name": "mailchecker", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "Cross-language temporary (disposable/throwaway) email detection library. Covers hundreds fake email providers.", | ||
@@ -5,0 +5,0 @@ "main": "platform/node/", |
/** | ||
* MailChecker.is_valid(String email); | ||
* MailChecker.isValid(String email); | ||
* @return {Boolean} true is the specified email is valid, false otherwise | ||
@@ -9,3 +9,3 @@ * | ||
* <script type="text/javascript"> | ||
* alert(MailChecker.is_valid("plop@plop.33mail.com")); | ||
* alert(MailChecker.isValid("plop@plop.33mail.com")); | ||
* </script> | ||
@@ -28,13 +28,13 @@ */ | ||
function all_domain_suffixes(email) { | ||
var domain_components = email.split('@')[1].split('.'); | ||
function allDomainSuffixes(email) { | ||
var domainComponents = email.split('@')[1].split('.'); | ||
return mapRange(0, domain_components.length, function (n) { | ||
return domain_components.slice(n).join('.'); | ||
return mapRange(0, domainComponents.length, function (n) { | ||
return domainComponents.slice(n).join('.'); | ||
}); | ||
} | ||
function is_blacklisted(email) { | ||
return all_domain_suffixes(email).some(function (domain_suffix) { | ||
return blacklist.indexOf(domain_suffix) >= 0; | ||
function isBlacklisted(email) { | ||
return allDomainSuffixes(email).some(function (domainSuffix) { | ||
return blacklist.indexOf(domainSuffix) >= 0; | ||
}); | ||
@@ -44,6 +44,6 @@ }; | ||
global.MailChecker = { | ||
is_valid: function (email){ | ||
isValid: function (email){ | ||
email = email.toLowerCase(); | ||
if(!isValidEmail.test(email)){return false;} | ||
return !is_blacklisted(email); | ||
return !isBlacklisted(email); | ||
}, | ||
@@ -50,0 +50,0 @@ blacklist: function () { |
/** | ||
* MailChecker.is_valid(String email); | ||
* MailChecker.isValid(String email); | ||
* @return {Boolean} true is the specified email is valid, false otherwise | ||
@@ -9,3 +9,3 @@ * | ||
* <script type="text/javascript"> | ||
* alert(MailChecker.is_valid("plop@plop.33mail.com")); | ||
* alert(MailChecker.isValid("plop@plop.33mail.com")); | ||
* </script> | ||
@@ -28,13 +28,13 @@ */ | ||
function all_domain_suffixes(email) { | ||
var domain_components = email.split('@')[1].split('.'); | ||
function allDomainSuffixes(email) { | ||
var domainComponents = email.split('@')[1].split('.'); | ||
return mapRange(0, domain_components.length, function (n) { | ||
return domain_components.slice(n).join('.'); | ||
return mapRange(0, domainComponents.length, function (n) { | ||
return domainComponents.slice(n).join('.'); | ||
}); | ||
} | ||
function is_blacklisted(email) { | ||
return all_domain_suffixes(email).some(function (domain_suffix) { | ||
return blacklist.indexOf(domain_suffix) >= 0; | ||
function isBlacklisted(email) { | ||
return allDomainSuffixes(email).some(function (domainSuffix) { | ||
return blacklist.indexOf(domainSuffix) >= 0; | ||
}); | ||
@@ -44,6 +44,6 @@ }; | ||
global.MailChecker = { | ||
is_valid: function (email){ | ||
isValid: function (email){ | ||
email = email.toLowerCase(); | ||
if(!isValidEmail.test(email)){return false;} | ||
return !is_blacklisted(email); | ||
return !isBlacklisted(email); | ||
}, | ||
@@ -50,0 +50,0 @@ blacklist: function () { |
@@ -5,5 +5,7 @@ /** | ||
* var MailChecker = require('mailchecker/platform/node') | ||
* MailChecker.is_valid(String email); | ||
* MailChecker.isValid(String email); | ||
* @return {Boolean} true is the specified email is valid, false otherwise | ||
*/ | ||
'use strict'; | ||
var range = require('node-range'); | ||
@@ -14,23 +16,28 @@ | ||
function all_domain_suffixes(email) { | ||
var domain_components = email.split('@')[1].split('.'); | ||
function allDomainSuffixes(email) { | ||
var domainComponents = email.split('@')[1].split('.'); | ||
return range(0, domain_components.length).map(function (n) { | ||
return domain_components.slice(n).join('.'); | ||
return range(0, domainComponents.length).map(function (n) { | ||
return domainComponents.slice(n).join('.'); | ||
}); | ||
} | ||
function is_blacklisted(email) { | ||
function suffix_is_blacklisted(domain_suffix) { | ||
return blacklist.indexOf(domain_suffix) >= 0; | ||
function isBlacklisted(email) { | ||
function suffixIsBlacklisted(domainSuffix) { | ||
return blacklist.indexOf(domainSuffix) >= 0; | ||
} | ||
return all_domain_suffixes(email).some(suffix_is_blacklisted); | ||
return allDomainSuffixes(email).some(suffixIsBlacklisted); | ||
}; | ||
module.exports = { | ||
is_valid: function (email){ | ||
isValid: function (email){ | ||
if (typeof(email) !== 'string') { | ||
return false; | ||
} | ||
email = email.toLowerCase(); | ||
if(!isValidEmail.test(email)){return false;} | ||
return !is_blacklisted(email); | ||
if (!isValidEmail.test(email)) { | ||
return false; | ||
} | ||
return !isBlacklisted(email); | ||
}, | ||
@@ -37,0 +44,0 @@ blacklist: function () { |
@@ -5,5 +5,7 @@ /** | ||
* var MailChecker = require('mailchecker/platform/node') | ||
* MailChecker.is_valid(String email); | ||
* MailChecker.isValid(String email); | ||
* @return {Boolean} true is the specified email is valid, false otherwise | ||
*/ | ||
'use strict'; | ||
var range = require('node-range'); | ||
@@ -14,23 +16,28 @@ | ||
function all_domain_suffixes(email) { | ||
var domain_components = email.split('@')[1].split('.'); | ||
function allDomainSuffixes(email) { | ||
var domainComponents = email.split('@')[1].split('.'); | ||
return range(0, domain_components.length).map(function (n) { | ||
return domain_components.slice(n).join('.'); | ||
return range(0, domainComponents.length).map(function (n) { | ||
return domainComponents.slice(n).join('.'); | ||
}); | ||
} | ||
function is_blacklisted(email) { | ||
function suffix_is_blacklisted(domain_suffix) { | ||
return blacklist.indexOf(domain_suffix) >= 0; | ||
function isBlacklisted(email) { | ||
function suffixIsBlacklisted(domainSuffix) { | ||
return blacklist.indexOf(domainSuffix) >= 0; | ||
} | ||
return all_domain_suffixes(email).some(suffix_is_blacklisted); | ||
return allDomainSuffixes(email).some(suffixIsBlacklisted); | ||
}; | ||
module.exports = { | ||
is_valid: function (email){ | ||
isValid: function (email){ | ||
if (typeof(email) !== 'string') { | ||
return false; | ||
} | ||
email = email.toLowerCase(); | ||
if(!isValidEmail.test(email)){return false;} | ||
return !is_blacklisted(email); | ||
if (!isValidEmail.test(email)) { | ||
return false; | ||
} | ||
return !isBlacklisted(email); | ||
}, | ||
@@ -37,0 +44,0 @@ blacklist: function () { |
@@ -40,3 +40,3 @@ # MailChecker | ||
if(!MailChecker.is_valid('myemail@yopmail.com')){ | ||
if(!MailChecker.isValid('myemail@yopmail.com')){ | ||
console.error('O RLY !'); | ||
@@ -46,3 +46,3 @@ process.exit(1); | ||
if(!MailChecker.is_valid('myemail.com')){ | ||
if(!MailChecker.isValid('myemail.com')){ | ||
console.error('O RLY !'); | ||
@@ -57,7 +57,7 @@ process.exit(1); | ||
<script type="text/javascript"> | ||
if(!MailChecker.is_valid('myemail@yopmail.com')){ | ||
if(!MailChecker.isValid('myemail@yopmail.com')){ | ||
console.error('O RLY !'); | ||
} | ||
if(!MailChecker.is_valid('myemail.com')){ | ||
if(!MailChecker.isValid('myemail.com')){ | ||
console.error('O RLY !'); | ||
@@ -64,0 +64,0 @@ } |
@@ -11,3 +11,3 @@ var _ = require('lodash'); | ||
function _is(b, email) { | ||
t.equal(MailChecker.is_valid(email), b, "MailChecker.is_valid(" + email + ") === " + b); | ||
t.equal(MailChecker.isValid(email), b, "MailChecker.isValid(" + email + ") === " + b); | ||
} | ||
@@ -29,2 +29,3 @@ var isValid = _is.bind(this, true); | ||
test('should return false if the email is invalid', function () { | ||
isInvalid(undefined); | ||
isInvalid("plopplop.com"); | ||
@@ -31,0 +32,0 @@ isInvalid("my+ok@ok=plop.com"); |
375314
1250