Merge branch 'main' into patch-1

This commit is contained in:
Jay Jackson
2021-05-20 13:09:40 -04:00
committed by GitHub
3 changed files with 18 additions and 2 deletions
+11
View File
@@ -0,0 +1,11 @@
{
"description": "medhanite is a dev",
"repo": "https://github.com/medhanite/medhanite.github.io",
"owner": {
"username": "EyobYb",
"email": "eyobyirgu@gmail.com"
},
"record": {
"CNAME": "medhanite.github.io"
}
}
+3
View File
@@ -31,6 +31,7 @@ describe('validateDomainData', () => {
{ ...defaultDomain, owner: { email: 'hwelo' }, },
{ ...defaultDomain, record: { CNAME: 'http://foobar.com' } },
{ ...defaultDomain, record: { CNAME: 'https://foobar.com' } },
{ ...defaultDomain, record: { URL: 'foobar.com' } },
];
const validCases = [
@@ -44,6 +45,8 @@ describe('validateDomainData', () => {
description: getstroflen(99),
},
{ ...defaultDomain, record: { CNAME: 'aa.sd', URL: '121,3213' } },
{ ...defaultDomain, record: { URL: 'https://foobar.com' } },
{ ...defaultDomain, record: { URL: 'http://foobar.com/foobar/' } },
];
it('should return false for invalid data', () => {
+4 -2
View File
@@ -2,11 +2,13 @@ const R = require('ramda');
const { VALID_RECORD_TYPES } = require('./constants');
const { or, and, validate, between, testRegex, withLengthEq, withLengthGte } = require('./helpers');
const isValidURL = testRegex(/^https?:\/\//ig);
const validateCnameRecord = key => and([
R.propSatisfies(R.is(String), key),
R.compose(withLengthEq(1), R.reject(R.equals('URL')), R.keys),
R.propSatisfies(withLengthGte(3), key),
R.propSatisfies(R.complement(testRegex(/^https?:\/\//ig)), key),
R.propSatisfies(R.complement(isValidURL), key),
]);
const validateARecord = key => and([
@@ -46,7 +48,7 @@ const validateDomainData = validate({
R.cond([
[R.has('CNAME'), validateCnameRecord('CNAME')],
[R.has('A'), validateARecord('A')],
[R.has('URL'), R.propSatisfies(R.is(String), 'URL')],
[R.has('URL'), R.propSatisfies(isValidURL, 'URL')],
[R.T, R.T],
]),
]),