public static URI getUrl()

in src/org/jetbrains/tfsIntegration/core/tfs/TfsUtil.java [150:184]


  public static URI getUrl(String uriText, boolean complainOnPath, boolean trimPath) {
    int i = uriText.indexOf(URLUtil.SCHEME_SEPARATOR);

    try {
      final URI uri;
      if (i == -1) {
        uri = new URI("http", "//" + uriText, null).normalize();
      }
      else {
        uri = new URI(uriText.substring(0, i), "//" + uriText.substring(i + URLUtil.SCHEME_SEPARATOR.length()), null).normalize();
      }
      if (StringUtil.isEmpty(uri.getHost())) {
        return null;
      }

      int port = uri.getPort();
      if (port > 0xFFFF) {
        return null;
      }

      if (complainOnPath && uri.getPath() != null && !uri.getPath().isEmpty() && !"/".equals(uri.getPath())) {
        return null;
      }
      if (trimPath) {
        return new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), "/", null, null);
      }
      else {
        return uri;
      }
    }
    catch (URISyntaxException e) {
      return null;
    }

  }