public static URL fromUri()

in webindex/modules/core/src/main/java/webindex/core/models/URL.java [244:270]


  public static URL fromUri(String uri) {
    String[] idArgs = uri.split(URI_SEP);
    if (idArgs.length != 4) {
      throw new IllegalArgumentException("Page ID has too few or many parts: " + uri);
    }
    String domain = idArgs[0];
    String host = idArgs[0] + idArgs[1];
    boolean ipHost = isValidIP(host);
    if (!ipHost) {
      domain = reverseHost(domain);
      host = reverseHost(host);
    }
    boolean secure = false;
    int port = 80;
    if (idArgs[2].startsWith("s")) {
      secure = true;
      port = 443;
    } else if (!idArgs[2].startsWith("o")) {
      throw new IllegalArgumentException(
          "Page ID does not have port info beg with 's' or 'o': " + uri);
    }
    if (idArgs[2].length() > 1) {
      port = Integer.parseInt(idArgs[2].substring(1));
    }
    String path = idArgs[3];
    return new URL(domain, host, path, port, secure, ipHost);
  }