diff --git a/index.js b/index.js index 73d15c9..c76d2b5 100644 --- a/index.js +++ b/index.js @@ -7,4 +7,4 @@ * stack@lebron.technology */ -module.exports = /^([\w_\.\-\+])+\@([\w\-]+\.)+([\w]{2,10})+$/; +module.exports = /^[a-z0-9ก-๛\-\._\+]+@[ก-๛a-z][ก-๛a-z0-9\+\-\.]*[ก-๛a-z]{2,}$/; diff --git a/test.js b/test.js index 3e8dd82..f0b3c15 100644 --- a/test.js +++ b/test.js @@ -16,6 +16,13 @@ describe('email regex', function() { assert.equal(regex.test('t.obi+_ferret@vision.com'), true); }); + it('should match thai input', function() { + assert.equal(regex.test('email-test@universal-acceptance-test.international'), true); + assert.equal(regex.test('email-test@universal-acceptance-test.icu'), true); + assert.equal(regex.test('อีเมลทดสอบ@ยูเอทดสอบ.ไทย'), true); + assert.equal(regex.test('อีเมลทดสอบ@ทีเอชนิค.องค์กร.ไทย'), true); + }); + it('should catch incorrect input', function() { assert.equal(regex.test('*(*(*()))'), false); assert.equal(regex.test('foobar@@hello.com'), false);