Permalink
Browse files

Merge pull request #138 from tofugear/master

fixes issue #129: only check tld if sld exists
  • Loading branch information...
derrickko committed Dec 7, 2016
2 parents 0f64eb9 + afca031 commit 24149b152d85110f584e722a06e9ebc6671e876b
Showing with 9 additions and 3 deletions.
  1. +7 −1 spec/mailcheckSpec.js
  2. +1 −1 src/mailcheck.js
  3. +1 −1 src/mailcheck.min.js
View
@@ -1,5 +1,5 @@
describe("mailcheck", function() {
var domains = ['google.com', 'gmail.com', 'emaildomain.com', 'comcast.net', 'facebook.com', 'msn.com', 'gmx.de'];
var domains = ['google.com', 'gmail.com', 'emaildomain.com', 'comcast.net', 'facebook.com', 'msn.com'];
var secondLevelDomains = ["yahoo", "hotmail", "mail", "live", "outlook", "gmx"];
var topLevelDomains = ['co.uk', 'com', 'org', 'info', 'fr'];
@@ -153,6 +153,12 @@ describe("mailcheck", function() {
mailcheck.suggest('test@gmx.fr', domains, secondLevelDomains, topLevelDomains)
).toBeFalsy();
});
it("will not offer suggestions for unrecognised 2ld's without a tld", function() {
expect(mailcheck.suggest('test@gm', domains, secondLevelDomains, topLevelDomains)).toBeFalsy();
expect(mailcheck.suggest('test@gma', domains, secondLevelDomains, topLevelDomains)).toBeFalsy();
expect(mailcheck.suggest('test@gmai', domains, secondLevelDomains, topLevelDomains)).toBeFalsy();
});
});
describe("mailcheck.splitEmail", function () {
View
@@ -86,7 +86,7 @@ var Mailcheck = {
rtrn = true;
}
if(closestTopLevelDomain && closestTopLevelDomain != emailParts.topLevelDomain) {
if(closestTopLevelDomain && closestTopLevelDomain != emailParts.topLevelDomain && emailParts.secondLevelDomain !== '') {
// The email address may have a mispelled top-level domain; return a suggestion
closestDomain = closestDomain.replace(new RegExp(emailParts.topLevelDomain + "$"), closestTopLevelDomain);
rtrn = true;
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 24149b1

Please sign in to comment.