diff --git a/tests/validations.test.js b/tests/validations.test.js index a2484d581..a07ccf6fa 100644 --- a/tests/validations.test.js +++ b/tests/validations.test.js @@ -63,6 +63,7 @@ describe('validateDomainData', () => { { ...defaultDomain, record: { AAAA: ['182.22.222.22', '::1'] } }, { ...defaultDomain, record: { AAAA: '182.22.222.22' } }, { ...defaultDomain, record: { A: '::1' } }, + { ...defaultDomain, name: '_discord' }, ]; const validCases = [ @@ -92,6 +93,7 @@ describe('validateDomainData', () => { { ...defaultDomain, record: { TXT: ['foobar wow nice!!!', 'more text'] } }, { ...defaultDomain, record: { AAAA: ['::1', '2001:db8:3333:4444:5555:6666:7777:8888'] } }, { ...defaultDomain, record: { A: ['122.222.222.222'] } }, + { ...defaultDomain, name: '_discord.subdomain' }, ]; it('should return false for invalid data', () => { diff --git a/utils/invalid-domains.json b/utils/invalid-domains.json index a8943f3c4..ef66a5517 100644 --- a/utils/invalid-domains.json +++ b/utils/invalid-domains.json @@ -14,5 +14,6 @@ "ww3", "ww4", "wwww", - "your-domain-name" + "your-domain-name", + "_discord" ] diff --git a/utils/validations.js b/utils/validations.js index 65d1c5336..b9c851a19 100644 --- a/utils/validations.js +++ b/utils/validations.js @@ -36,6 +36,11 @@ const validateAAAARecord = R.propSatisfies(and([ const checkRestrictedNames = R.complement(R.includes(R.__, INVALID_NAMES)) +const extraSupportedNames = [ + testRegex(/^_github(-pages)?-challenge-[a-z0-9-_]+$/i), // Exception for github verification records + R.equals('_discord'), +] + const validateDomainData = validate({ name: { reason: 'The name of the file is invalid. It must be lowercased, alphanumeric and each component must be more than 2 characters long', @@ -43,17 +48,15 @@ const validateDomainData = validate({ R.equals('@'), and([ R.is(String), + checkRestrictedNames, R.compose( R.all(or([ - and([ - testRegex(/^_github(-pages)?-challenge-[a-z0-9-_]+$/i), // Exception for github verification records - checkRestrictedNames, - ]), and([ R.compose(between(2, 100), R.length), testRegex(/^[a-z0-9-]+$/g), checkRestrictedNames, - ]) + ]), + ...extraSupportedNames, ])), R.split('.'), ),