1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 01:25:17 +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() {
let { host } = window.location;
let matchedHost = host.match(/(([^.]+)\.)?(.*)\.(.*)/);
return matchedHost[2] || 'www';
let tokens = host.split('.');
return tokens.length > 2 ? tokens[0] : 'www';
}