mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-08-05 12:23:31 +00:00
Merge pull request #3445 from is-a-dev/feature/github-verification-record
feat(validation): adds exception for github verification records
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
@@ -11,5 +11,6 @@
|
||||
"ww1",
|
||||
"ww2",
|
||||
"ww3",
|
||||
"ww4"
|
||||
"ww4",
|
||||
"_github-pages-challenge-is-a-dev"
|
||||
]
|
||||
|
||||
+12
-4
@@ -25,6 +25,8 @@ const validateMXRecord = type => and([
|
||||
R.propSatisfies(R.all(isValidDomain), type),
|
||||
]);
|
||||
|
||||
const checkRestrictedNames = R.complement(R.includes(R.__, INVALID_NAMES))
|
||||
|
||||
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',
|
||||
@@ -33,10 +35,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
|
||||
checkRestrictedNames,
|
||||
]),
|
||||
and([
|
||||
R.compose(between(2, 100), R.length),
|
||||
testRegex(/^[a-z0-9-]+$/g),
|
||||
checkRestrictedNames,
|
||||
])
|
||||
])),
|
||||
R.split('.'),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user