Skip to content

Commit

Permalink
one letter tld not allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
fredeil committed Jun 18, 2024
1 parent 6dd5cab commit 98972bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/email_validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ class EmailValidator {
_index++;
}

// 1 letter tld is not valid
if (_index == text.length && (_index - startIndex) == 1) {
return false;
}

return (_index - startIndex) < 64 && text[_index - 1] != '-';
}

Expand Down
1 change: 1 addition & 0 deletions test/email_validator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void main() {
'the-total-length@of-an-entire-address.cannot-be-longer-than-two-hundred-and-fifty-four-characters.and-this-address-is-255-characters-exactly.so-it-should-be-invalid.and-im-going-to-add-some-more-words-here.to-increase-the-lenght-blah-blah-blah-blah-bl.org',
'[email protected]',
'[email protected]',
'[email protected]',

// examples of real (invalid) input from real users.
'No longer available.',
Expand Down

0 comments on commit 98972bc

Please sign in to comment.