feat(validation): adds exception for github verification records

This commit is contained in:
Akshay Nair
2022-09-11 23:49:45 +05:30
parent bc17e0c226
commit d22025fb37
3 changed files with 16 additions and 5 deletions
+4
View File
@@ -58,6 +58,7 @@ describe('validateDomainData', () => {
{ ...defaultDomain, name: 'a.b' },
{ ...defaultDomain, name: 'ww2.baa' },
{ ...defaultDomain, name: 'help.baa' },
{ ...defaultDomain, name: '_github-pages-challenge-is-a-dev' },
];
const validCases = [
@@ -78,6 +79,9 @@ describe('validateDomainData', () => {
{ ...defaultDomain, record: { A: ['1.1.1.1'], MX: ['mx1.example.com'] } },
{ ...defaultDomain, name: 'gogo.foo.bar' },
{ ...defaultDomain, name: 'ww9.baa' },
{ ...defaultDomain, name: '_github-pages-challenge-phenax.akshay' },
{ ...defaultDomain, name: '_github-pages-challenge-hello01-ga' },
{ ...defaultDomain, name: '_github-pages-challenge-hello01_ga' },
];
it('should return false for invalid data', () => {
+2 -1
View File
@@ -11,5 +11,6 @@
"ww1",
"ww2",
"ww3",
"ww4"
"ww4",
"_github-pages-challenge-is-a-dev"
]
+10 -4
View File
@@ -33,10 +33,16 @@ const validateDomainData = validate({
and([
R.is(String),
R.compose(
R.all(and([
R.compose(between(2, 100), R.length),
testRegex(/^[a-z0-9-]+$/g),
R.complement(R.includes(R.__, INVALID_NAMES)),
R.all(or([
and([
testRegex(/^_github-pages-challenge-[a-z0-9-_]+$/i), // Exception for github verification records
R.complement(R.includes(R.__, INVALID_NAMES)),
]),
and([
R.compose(between(2, 100), R.length),
testRegex(/^[a-z0-9-]+$/g),
R.complement(R.includes(R.__, INVALID_NAMES)),
])
])),
R.split('.'),
),