diff --git a/domains/medhanite.json b/domains/medhanite.json new file mode 100644 index 000000000..82ffc98e9 --- /dev/null +++ b/domains/medhanite.json @@ -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" + } +} diff --git a/tests/validations.test.js b/tests/validations.test.js index 057ffc3c8..2971b82a7 100644 --- a/tests/validations.test.js +++ b/tests/validations.test.js @@ -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', () => { diff --git a/utils/validations.js b/utils/validations.js index 4d0444816..7365a2ab0 100644 --- a/utils/validations.js +++ b/utils/validations.js @@ -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], ]), ]),