mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-08-13 16:22:52 +00:00
Merge branch 'main' into patch-1
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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],
|
||||
]),
|
||||
]),
|
||||
|
||||
Reference in New Issue
Block a user