/** * Resolve a `server` config value into a full base URL for `@tlecommunity/client`. * * Ported from the old `emissary.getUrl` host logic: a value that already looks * like a URL is used as-is (normalised to exactly one trailing slash, which is * what the client's own `Config` does); a bare shortname such as `us1` becomes * `http://us1.lacunaexpanse.com/` (https in the browser, matching the page). * * @param {string} server - a full `http(s)://host` URL or a bare server shortname * @return {string} the base URL, guaranteed to end in `/` */ export function resolveServerUrl(server) { if (!server) { throw 'No server configured' } const value = String(server) if (value.startsWith('http')) { return value.endsWith('/') ? value : `${value}/` } const protocol = typeof window !== 'undefined' ? window.location.protocol : 'http:' return `${protocol}//${value}.lacunaexpanse.com/` }