Attempt to provision subdomain on team create

This commit is contained in:
Tom Moor
2018-11-04 15:02:27 -08:00
parent 6391474d14
commit c323de4807
6 changed files with 53 additions and 5 deletions

View File

@@ -1,35 +0,0 @@
// @flow
import parseDomain from 'parse-domain';
export function stripSubdomain(hostname: string) {
const parsed = parseDomain(hostname);
if (!parsed) return hostname;
if (parsed.tld) return `${parsed.domain}.${parsed.tld}`;
return parsed.domain;
}
export const RESERVED_SUBDOMAINS = [
'admin',
'api',
'beta',
'blog',
'cdn',
'community',
'developer',
'forum',
'help',
'imap',
'localhost',
'mail',
'ns1',
'ns2',
'ns3',
'ns4',
'smtp',
'support',
'status',
'static',
'test',
'www',
];

View File

@@ -1,17 +0,0 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import { stripSubdomain } from './domains';
describe('#stripSubdomain', () => {
test('to work with localhost', () => {
expect(stripSubdomain('localhost')).toBe('localhost');
});
test('to return domains without a subdomain', () => {
expect(stripSubdomain('example')).toBe('example');
expect(stripSubdomain('example.com')).toBe('example.com');
expect(stripSubdomain('example.org:3000')).toBe('example.org');
});
test('to remove subdomains', () => {
expect(stripSubdomain('test.example.com')).toBe('example.com');
expect(stripSubdomain('test.example.com:3000')).toBe('example.com');
});
});