export const actualCurrentHost = window.location.hostname;
export const isLocalhost = ["127.0.0.1", "localhost"].includes(actualCurrentHost);
export const getCurrentHost = (localhostHost) => {
    if (!isLocalhost)
        return actualCurrentHost;
    const lh = localhostHost.split(/,/)[0]; // assume could be a list of hosts
    return lh;
};
const win = window;
export const replaceHost = (host) => 
// eslint-disable-next-line prettier/prettier
`https://${host || window.location.host}${window.location.pathname}${window.location.search ? "?" + window.location.search : ""}`;
if (window.location.protocol != "https:" && !isLocalhost)
    window.location = replaceHost();
// `https://${window.location.host}${window.location.pathname}${window.location.search ? "?" + window.location.search : ""}`;
export const ensureCanonicalHost = (canonicalHosts = {}, stage) => {
    const canonicalHostsForStage = (canonicalHosts[stage] || "").split(/,/);
    if (!isLocalhost && canonicalHostsForStage.length && !canonicalHostsForStage.includes(actualCurrentHost))
        window.location = `httpges://${canonicalHostsForStage[0]}${window.location.pathname}${window.location.search ? "?" + window.location.search : ""}`;
};
export const ensureProtocol = () => {
    if (window.location.protocol != "https:" && !isLocalhost)
        window.location = replaceHost();
};
export const ensureProtocolAndHost = (canonicalHosts = {}, stage) => {
    ensureProtocol();
    ensureCanonicalHost(canonicalHosts, stage);
};
//# sourceMappingURL=hosts.js.map