feat(script): allows _discord subdomains

This commit is contained in:
Akshay Nair
2023-09-22 22:16:48 +05:30
parent 44753fa2f1
commit b54ca58577
3 changed files with 12 additions and 6 deletions
+2
View File
@@ -59,6 +59,7 @@ describe('validateDomainData', () => {
{ ...defaultDomain, name: 'help.baa' },
{ ...defaultDomain, name: '_github-pages-challenge-is-a-dev' },
{ ...defaultDomain, name: '_github-challenge-is-a-dev' },
{ ...defaultDomain, name: '_discord' },
];
const validCases = [
@@ -86,6 +87,7 @@ describe('validateDomainData', () => {
{ ...defaultDomain, name: '_github-challenge-hello01-ga' },
{ ...defaultDomain, name: '_github-challenge-hello01_ga' },
{ ...defaultDomain, record: { TXT: ['foobar wow nice!!!', 'more text'] } },
{ ...defaultDomain, name: '_discord.subdomain' },
];
it('should return false for invalid data', () => {
+2 -1
View File
@@ -14,5 +14,6 @@
"ww3",
"ww4",
"wwww",
"your-domain-name"
"your-domain-name",
"_discord"
]
+8 -5
View File
@@ -27,6 +27,11 @@ const validateMXRecord = type => 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',
@@ -34,17 +39,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('.'),
),