File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -377,6 +377,48 @@ describe('Validators', () => {
377377 } ) ;
378378 } ) ;
379379
380+ it ( 'should reject email addresses with zero-width characters when allow_zero_width is false' , ( ) => {
381+ test ( {
382+ validator : 'isEmail' ,
383+ args : [ { allow_zero_width : false } ] ,
384+ valid : [
385+ 'foo@bar.com' ,
386+ 'test@example.com' ,
387+ 'user+tag@domain.co.uk' ,
388+ ] ,
389+ invalid : [
390+ 'foo\u200B@bar.com' ,
391+ 'foo@bar\u200B.com' ,
392+ 'test\u200C@example.com' ,
393+ 'test@exam\u200Cple.com' ,
394+ 'user\u200D@domain.com' ,
395+ 'user@dom\u200Dain.com' ,
396+ 'admin\uFEFF@site.com' ,
397+ 'admin@si\uFEFFte.com' ,
398+ ] ,
399+ } ) ;
400+ } ) ;
401+
402+ it ( 'should allow email addresses with zero-width characters by default' , ( ) => {
403+ test ( {
404+ validator : 'isEmail' ,
405+ valid : [
406+ 'foo@bar.com' ,
407+ 'test@example.com' ,
408+ 'foo\u200B@bar.com' ,
409+ 'foo@bar\u200B.com' ,
410+ 'test\u200C@example.com' ,
411+ 'user\u200D@domain.com' ,
412+ 'admin\uFEFF@site.com' ,
413+ ] ,
414+ invalid : [
415+ 'invalidemail@' ,
416+ 'invalid.com' ,
417+ '@invalid.com' ,
418+ ] ,
419+ } ) ;
420+ } ) ;
421+
380422 it ( 'should validate URLs' , ( ) => {
381423 test ( {
382424 validator : 'isURL' ,
You can’t perform that action at this time.
0 commit comments