aboutsummaryrefslogtreecommitdiff
path: root/webAO/client/aoHost.ts
blob: 0d7cb0f106b2b22b1f092c27c593034aafe8d667 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import queryParser from "../utils/queryParser";

const { asset } = queryParser();
export let AO_HOST = asset;
export const setAOhost = (val: string): string => {
  const currentProtocol = window.location.protocol;
  const assetProtocol = val.split(":")[0] + ":";

  if (currentProtocol === "https:" && assetProtocol === "http:") {
    // In this specific case, we need to request assets over HTTPS
    console.log("Upgrading asset link to https");
    val = val.replace("http:", "https:");
  }
  if (
    AO_HOST.length < 5 ||
    !AO_HOST ||
    AO_HOST.includes(`//attorneyoffline.de/`)
  ) {
    AO_HOST = val;
  }
  console.log("Asset URL ist now " + AO_HOST);
  return AO_HOST;
};