mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-14 14:17:38 +00:00
feat: adds support for dots in subdomain names
This commit is contained in:
3 files changed
+20
-6
No files matched your search
@@ -4,6 +4,9 @@ To register `my-domain.is-a.dev`, you need to create a `domains/my-domain.json`
|
|||||||
|
|
||||||
### Filename
|
### Filename
|
||||||
The file name must pass the following criteria -
|
The file name must pass the following criteria -
|
||||||
|
|
||||||
|
> NOTE: You can use `.` (dots) in your file name (for registering `blog.mysubdomain.is-a.dev`) but each of the following criteria must be valid for all part of your subdomain
|
||||||
|
|
||||||
* Must be alpha-numeric in lowercase with dashes as seperators
|
* Must be alpha-numeric in lowercase with dashes as seperators
|
||||||
* Must be more than 2 characters long
|
* Must be more than 2 characters long
|
||||||
* Must have a `.json` file extension
|
* Must have a `.json` file extension
|
||||||
@@ -25,7 +28,7 @@ In the owner object, the fields `username` and `email` are required. You can how
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
If you don't wish to share your email address here, please share your twitter or any other social media account.
|
If you don't wish to share your email address here, please share your twitter, discord or any other social media account.
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"owner": {
|
"owner": {
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ describe('validateDomainData', () => {
|
|||||||
{ ...defaultDomain, record: { CNAME: 'foobar.com', MX: ['ALT4.ASPMX.L.GOOGLE.COM'] } },
|
{ ...defaultDomain, record: { CNAME: 'foobar.com', MX: ['ALT4.ASPMX.L.GOOGLE.COM'] } },
|
||||||
...INVALID_NAMES.map(name => ({ ...defaultDomain, name })).slice(0, 1),
|
...INVALID_NAMES.map(name => ({ ...defaultDomain, name })).slice(0, 1),
|
||||||
{ ...defaultDomain, record: { TXT: ['foobar wow nice!!!'] } },
|
{ ...defaultDomain, record: { TXT: ['foobar wow nice!!!'] } },
|
||||||
|
{ ...defaultDomain, name: 'a.b' },
|
||||||
|
{ ...defaultDomain, name: 'ww2.baa' },
|
||||||
|
{ ...defaultDomain, name: 'help.baa' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const validCases = [
|
const validCases = [
|
||||||
@@ -73,6 +76,8 @@ describe('validateDomainData', () => {
|
|||||||
{ ...defaultDomain, record: { MX: ['ALT4.ASPMX.L.GOOGLE.COM'] } },
|
{ ...defaultDomain, record: { MX: ['ALT4.ASPMX.L.GOOGLE.COM'] } },
|
||||||
{ ...defaultDomain, record: { TXT: 'foobar wow nice!!!' } },
|
{ ...defaultDomain, record: { TXT: 'foobar wow nice!!!' } },
|
||||||
{ ...defaultDomain, record: { A: ['1.1.1.1'], MX: ['mx1.example.com'] } },
|
{ ...defaultDomain, record: { A: ['1.1.1.1'], MX: ['mx1.example.com'] } },
|
||||||
|
{ ...defaultDomain, name: 'gogo.foo.bar' },
|
||||||
|
{ ...defaultDomain, name: 'ww9.baa' },
|
||||||
];
|
];
|
||||||
|
|
||||||
it('should return false for invalid data', () => {
|
it('should return false for invalid data', () => {
|
||||||
|
|||||||
+11
-5
@@ -5,7 +5,7 @@ const INVALID_NAMES = require('./invalid-domains.json');
|
|||||||
|
|
||||||
const isValidURL = and([R.is(String), testRegex(/^https?:\/\//ig)]);
|
const isValidURL = and([R.is(String), testRegex(/^https?:\/\//ig)]);
|
||||||
|
|
||||||
const isValidDomain = and([R.is(String), testRegex(/^(([a-z0-9\-]+)\.)+[a-z]+$/ig)]);
|
const isValidDomain = and([R.is(String), testRegex(/^(([a-z0-9-]+)\.)+[a-z]+$/ig)]);
|
||||||
|
|
||||||
const validateCnameRecord = type => and([
|
const validateCnameRecord = type => and([
|
||||||
R.propIs(String, type),
|
R.propIs(String, type),
|
||||||
@@ -27,13 +27,19 @@ const validateMXRecord = type => and([
|
|||||||
|
|
||||||
const validateDomainData = validate({
|
const validateDomainData = validate({
|
||||||
name: {
|
name: {
|
||||||
reason: 'The name of the file is invalid. It must be lowercased, alphanumeric and more than 2 characters long',
|
reason: 'The name of the file is invalid. It must be lowercased, alphanumeric and each component must be more than 2 characters long',
|
||||||
fn: or([
|
fn: or([
|
||||||
R.equals('@'),
|
R.equals('@'),
|
||||||
and([
|
and([
|
||||||
R.compose(between(2, 100), R.length),
|
R.is(String),
|
||||||
testRegex(/^[a-z0-9-]+$/g),
|
R.compose(
|
||||||
R.complement(R.includes(R.__, INVALID_NAMES)),
|
R.all(and([
|
||||||
|
R.compose(between(2, 100), R.length),
|
||||||
|
testRegex(/^[a-z0-9-]+$/g),
|
||||||
|
R.complement(R.includes(R.__, INVALID_NAMES)),
|
||||||
|
])),
|
||||||
|
R.split('.'),
|
||||||
|
),
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user