1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

PR Feedback: Simplify subdomain extraction

This commit is contained in:
Tim Daubenschütz 2015-09-30 11:09:04 +02:00
parent d50d0faabe
commit aa908a1c57

View File

@ -230,6 +230,6 @@ export function truncateTextAtCharIndex(text, charIndex, replacement = '...') {
*/ */
export function getSubdomain() { export function getSubdomain() {
let { host } = window.location; let { host } = window.location;
let matchedHost = host.match(/(([^.]+)\.)?(.*)\.(.*)/); let tokens = host.split('.');
return matchedHost[2] || 'www'; return tokens.length > 2 ? tokens[0] : 'www';
} }