1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/js/utils/constants_utils.js
Brett Sun c335dd3882 On subdomain get error, use the default subdomain settings
Also small cleanups and avoids adding `client—undefined` class to body
for default subdomain
2016-01-04 13:08:32 +01:00

21 lines
659 B
JavaScript

'use strict';
import AppConstants from '../constants/application_constants';
export function getDefaultSubdomainSettings() {
return AppConstants.defaultDomain;
}
export function getSubdomainSettings(subdomain) {
const settings = AppConstants.subdomains.filter((sdSettings) => subdomain === sdSettings.subdomain);
if (settings.length === 1) {
return settings[0];
} else if (settings.length === 0) {
console.warn('There are no subdomain settings for the subdomain: ' + subdomain);
return AppConstants.defaultDomain;
} else {
throw new Error('Matched multiple subdomains. Adjust constants file.');
}
}