Skip to content
This repository was archived by the owner on Apr 19, 2022. It is now read-only.

Commit bd90485

Browse files
carlsonorozcothetutlage
authored andcommitted
feat(raw): allow 63 characters long TLD in email
1 parent b0ee84a commit bd90485

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/Raw/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const moment = require('moment')
1414
/**
1515
* list of creepy regex, no they work nice
1616
*/
17-
const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i
18-
const emailRegex = /^([\w-]+(?:\.[\w-]+)*)(\+[\w\.-]+)?@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
17+
const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i
18+
const emailRegex = /^([\w-]+(?:\.[\w-]+)*)(\+[\w\.-]+)?@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,63}(?:\.[a-z]{2})?)$/i
1919
const phoneRegex = /\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/
2020
const creditCardRegex = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\d{3})\d{11})$/
2121
const alphaNumericRegex = /^[a-z0-9]+$/i

test/raw.spec.js

+26-2
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,22 @@ describe('Raw Validator', function() {
451451
expect(isUrl).to.equal(true)
452452
})
453453

454+
//////////////////////////
455+
// test suite add later //
456+
//////////////////////////
457+
it('should return true when input contains 63 characters TLD', function () {
458+
const isUrl = Is.url('https://example.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk')
459+
expect(isUrl).to.equal(true)
460+
})
461+
462+
//////////////////////////
463+
// test suite add later //
464+
//////////////////////////
465+
it('should return false when input contains more than 63 characters TLD', function () {
466+
const isUrl = Is.url('https://example.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl')
467+
expect(isUrl).to.equal(false)
468+
})
469+
454470
///////////////////
455471
// test suite 55 //
456472
///////////////////
@@ -486,11 +502,19 @@ describe('Raw Validator', function() {
486502
///////////////////
487503
// test suite 59 //
488504
///////////////////
489-
it('should return true when input is a valid email address with different TLD', function () {
490-
const isEmail = Is.email('someone@example.org')
505+
it('should return true when input is a valid email address with 63 characters TLD', function () {
506+
const isEmail = Is.email('someone@example.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk')
491507
expect(isEmail).to.equal(true)
492508
})
493509

510+
//////////////////////////
511+
// test suite add later //
512+
//////////////////////////
513+
it('should return false when input is not a valid email address with more than 63 characters TLD', function () {
514+
const isEmail = Is.email('someone@example.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl')
515+
expect(isEmail).to.equal(false)
516+
})
517+
494518
//////////////////////////
495519
// test suite add later //
496520
//////////////////////////

0 commit comments

Comments
 (0)