code: protected String getSecureBaseUrl(String siteUrl) {
      if(!siteUrl.startsWith("http://") && !siteUrl.startsWith("https://")) {
        siteUrl = "http://" + siteUrl;
      }
      Matcher urlMatcher = URL_PATTERN.matcher(siteUrl);
      if(urlMatcher.matches()) {
        logger.debug("Url matches [{}]", siteUrl);
        boolean local = false;
        try {
          logger.debug("Checking if host [{}] is local", urlMatcher.group(1));
          InetAddress hostAddr = InetAddress.getByName(urlMatcher.group(1));
          local = hostAddr.isLoopbackAddress() || hostAddr.isSiteLocalAddress();
          logger.debug("IpAddress [{}] local: {}", hostAddr.getHostAddress(), local);
        } catch(UnknownHostException e) {
          logger.warn("Hostname not found ["+siteUrl+"]", e);
        }
        if(!local) {
          return siteUrl.replaceFirst("http://", "https://");
        }
      }
      return siteUrl;
    }
docs: Converts the passed in siteUrl to be https if not already or not local.
  
  @param siteUrl The url of a cadmium site.
  @return The passed in siteUrl or the same url but converted to https.