Closes #805 - Unable to signin on self-hosted installations with non-www subdomain
This commit is contained in:
@@ -9,6 +9,13 @@ export function stripSubdomain(hostname: string) {
|
||||
return parsed.domain;
|
||||
}
|
||||
|
||||
export function isCustomSubdomain(hostname: string) {
|
||||
const parsed = parseDomain(hostname);
|
||||
if (!parsed) return false;
|
||||
if (!parsed.subdomain || parsed.subdomain === 'www') return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
export const RESERVED_SUBDOMAINS = [
|
||||
'about',
|
||||
'account',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable flowtype/require-valid-file-annotation */
|
||||
import { stripSubdomain } from './domains';
|
||||
import { stripSubdomain, isCustomSubdomain } from './domains';
|
||||
|
||||
describe('#stripSubdomain', () => {
|
||||
test('to work with localhost', () => {
|
||||
@@ -15,3 +15,22 @@ describe('#stripSubdomain', () => {
|
||||
expect(stripSubdomain('test.example.com:3000')).toBe('example.com');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isCustomSubdomain', () => {
|
||||
test('to work with localhost', () => {
|
||||
expect(isCustomSubdomain('localhost')).toBe(false);
|
||||
});
|
||||
test('to return false for domains without a subdomain', () => {
|
||||
expect(isCustomSubdomain('example')).toBe(false);
|
||||
expect(isCustomSubdomain('example.com')).toBe(false);
|
||||
expect(isCustomSubdomain('example.org:3000')).toBe(false);
|
||||
});
|
||||
test('to return false for www', () => {
|
||||
expect(isCustomSubdomain('www.example.com')).toBe(false);
|
||||
expect(isCustomSubdomain('www.example.com:3000')).toBe(false);
|
||||
});
|
||||
test('to return true for subdomains', () => {
|
||||
expect(isCustomSubdomain('test.example.com')).toBe(true);
|
||||
expect(isCustomSubdomain('test.example.com:3000')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user