mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-16 08:15:19 +00:00
validations: adds restrictions to allowed subdomain names
This commit is contained in:
1 parent
ca643bba35
commit
1e77efae8b
3 files changed
+16
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
const { validateDomainData, isValidDomain } = require('../utils/validations');
|
const { validateDomainData, isValidDomain } = require('../utils/validations');
|
||||||
|
const INVALID_NAMES = require('../utils/invalid-domains.json');
|
||||||
|
|
||||||
const defaultDomain = {
|
const defaultDomain = {
|
||||||
name: 'aaa',
|
name: 'aaa',
|
||||||
@@ -52,6 +53,7 @@ describe('validateDomainData', () => {
|
|||||||
{ ...defaultDomain, record: { CNAME: 'https://foobar.com' } },
|
{ ...defaultDomain, record: { CNAME: 'https://foobar.com' } },
|
||||||
{ ...defaultDomain, record: { URL: 'foobar.com' } },
|
{ ...defaultDomain, record: { URL: 'foobar.com' } },
|
||||||
{ ...defaultDomain, record: { CNAME: 'foobar.com', A: ['11.22.22.33'] } },
|
{ ...defaultDomain, record: { CNAME: 'foobar.com', A: ['11.22.22.33'] } },
|
||||||
|
...INVALID_NAMES.map(name => ({ ...defaultDomain, name })).slice(0, 1),
|
||||||
];
|
];
|
||||||
|
|
||||||
const validCases = [
|
const validCases = [
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
[
|
||||||
|
"help",
|
||||||
|
"support",
|
||||||
|
"no-reply",
|
||||||
|
"noreply",
|
||||||
|
"notifications",
|
||||||
|
"notification",
|
||||||
|
"ww1",
|
||||||
|
"ww2",
|
||||||
|
"ww3",
|
||||||
|
"ww4"
|
||||||
|
]
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
const R = require('ramda');
|
const R = require('ramda');
|
||||||
const { VALID_RECORD_TYPES } = require('./constants');
|
const { VALID_RECORD_TYPES } = require('./constants');
|
||||||
const { or, and, validate, between, testRegex, withLengthEq, withLengthGte } = require('./helpers');
|
const { or, and, validate, between, testRegex, withLengthEq, withLengthGte } = require('./helpers');
|
||||||
|
const INVALID_NAMES = require('./invalid-domains.json');
|
||||||
|
|
||||||
const isValidURL = testRegex(/^https?:\/\//ig);
|
const isValidURL = testRegex(/^https?:\/\//ig);
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ const validateDomainData = validate({
|
|||||||
and([
|
and([
|
||||||
R.compose(between(2, 100), R.length),
|
R.compose(between(2, 100), R.length),
|
||||||
testRegex(/^[a-z0-9-]+$/g),
|
testRegex(/^[a-z0-9-]+$/g),
|
||||||
|
R.complement(R.includes(R.__, INVALID_NAMES)),
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user