Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
fixed email validation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkingshott committed Jul 27, 2022
1 parent 394408a commit 84c6e43
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kingshott/iodine",
"version": "8.1.0",
"version": "8.2.0",
"description": "A micro client-side validation library",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/iodine.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export default class Iodine
*/
assertEmail(value)
{
let regex = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
let regex = "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$";

return new RegExp(regex).test(String(value).toLowerCase());
}
Expand Down
2 changes: 2 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ test('email values', () =>
expect(window.Iodine.assertEmail('[email protected]')).toBe(true);
expect(window.Iodine.assertEmail('😃@i.com')).toBe(false);
expect(window.Iodine.assertEmail('')).toBe(false);
expect(window.Iodine.assertEmail('[email protected] ')).toBe(false);
expect(window.Iodine.assertEmail('[email protected] extra')).toBe(false);
expect(window.Iodine.assertEmail('45454.com')).toBe(false);
expect(window.Iodine.assertEmail('sdfsf@')).toBe(false);
});
Expand Down

0 comments on commit 84c6e43

Please sign in to comment.