Identifies the Service Vendor based on the given URL
@param url Base URL to check
@return Service Enum found or unsupported
506553
public static Service identify(String url) {
    Service answer = Service.UNSUPPORTED;
    int index = url.indexOf(COMPOSUM_URL);
    if (index > 0) {
      answer = Service.COMPOSUM;
    }
    else {
      index = url.indexOf(CRX_URL);
      if (index > 0) {
        answer = Service.CRX;
      }
    }
    return answer;
  }
229711
def get_sanitized_endpoint(url):
    
    # sanitize esri
    sanitized_url = url.rstrip()
    esri_string = '/rest/services'
    if esri_string in url:
        match = re.search(esri_string, sanitized_url)
        sanitized_url = url[0:(match.start(0)+len(esri_string))]
    return sanitized_url
330007
public static Map.Entry<String,Integer> findUrlAndPort( String url ) {

		Matcher m = Pattern.compile( ".*(:\\d+).*" ).matcher( url );
		String portAsString = m.find() ? m.group( 1 ).substring( 1 ) : null;
		Integer port = portAsString == null ? - 1 : Integer.parseInt( portAsString );
		String address = portAsString == null ? url : url.replace( m.group( 1 ), "" );

		return new AbstractMap.SimpleEntry<>( address, port );
	}
1103436
public static boolean isExternalUrl(String url) {
        return URL_PATTERN.matcher(url).matches() || SPECIAL_URL_PATTERN.matcher(url).matches();
    }
887680
public static VendorPackageInstaller getPackageInstaller(String url) throws PackageManagerException {
    VendorPackageInstaller answer;
    switch (identify(url)) {
      case COMPOSUM:
        answer = new ComposumPackageInstaller(url);
        break;
      case CRX:
        answer = new CrxPackageInstaller(url);
        break;
      default:
        throw new PackageManagerException("Given URL is not supported: " + url);
    }
    return answer;
  }
885512
public static ServiceDependencyBuilder serviceDependency(final String url) {
        return new ServiceDependencyBuilder()
                .withUrl(url)
                .withType(ServiceDependency.TYPE_SERVICE)
                .withSubtype(ServiceDependency.SUBTYPE_OTHER);
    }
491030
@SuppressWarnings("StringSplitter")
    private boolean matchNonProxy(final URL url) {
        final String host = url.getHost();

        // code partially from org.apache.maven.plugins.site.AbstractDeployMojo#getProxyInfo
        final String nonProxyHosts = settings.getString(Settings.KEYS.PROXY_NON_PROXY_HOSTS);
        if (null != nonProxyHosts) {
            final String[] nonProxies = nonProxyHosts.split("(,)|(;)|(\\|)");
            for (final String nonProxyHost : nonProxies) {
                //if ( StringUtils.contains( nonProxyHost, "*" ) )
                if (null != nonProxyHost && nonProxyHost.contains("*")) {
                    // Handle wildcard at the end, beginning or middle of the nonProxyHost
                    final int pos = nonProxyHost.indexOf('*');
                    final String nonProxyHostPrefix = nonProxyHost.substring(0, pos);
                    final String nonProxyHostSuffix = nonProxyHost.substring(pos + 1);
                    // prefix*
                    if (!StringUtils.isEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix) && StringUtils.isEmpty(nonProxyHostSuffix)) {
                        return true;
                    }
                    // *suffix
                    if (StringUtils.isEmpty(nonProxyHostPrefix) && !StringUtils.isEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) {
                        return true;
                    }
                    // prefix*suffix
                    if (!StringUtils.isEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix) && !StringUtils.isEmpty(nonProxyHostSuffix)
                            && host.endsWith(nonProxyHostSuffix)) {
                        return true;
                    }
                } else if (host.equals(nonProxyHost)) {
                    return true;
                }
            }
        }
        return false;
    }
436095
protected String normalizeUrl(String url) {
    try {
      URL requestURL = new URL(url);
      StringBuilder normalized = new StringBuilder(requestURL.getProtocol().toLowerCase()).append("://").append(requestURL.getHost().toLowerCase());
      if ((requestURL.getPort() >= 0) && (requestURL.getPort() != requestURL.getDefaultPort())) {
        normalized.append(":").append(requestURL.getPort());
      }
      normalized.append(requestURL.getPath());
      return normalized.toString();
    }
    catch (MalformedURLException e) {
      throw new IllegalStateException("Illegal URL for calculating the OAuth signature.", e);
    }
  }
842644
public ParameterParser getUrlParamParser(String url) {
		List<Context> contexts = getContextsForUrl(url);
		if (contexts.size() > 0) {
			return contexts.get(0).getUrlParamParser();
		}
		return this.defaultParamParser;
	}
17635
public static String urlToString(URL url) {
        return Checker.isNull(url) ? "" : url.toString().replaceAll("file:" + (Checker.isWindows() ? "/?" : ""), "");
    }
633123
def service_url_parse(url):
    
    endpoint = get_sanitized_endpoint(url)
    url_split_list = url.split(endpoint + '/')
    if len(url_split_list) != 0:
        url_split_list = url_split_list[1].split('/')
    else:
        raise Exception('Wrong url parsed')

    # Remove unnecessary items from list of the split url.
    parsed_url = [s for s in url_split_list if '?' not in s if 'Server' not in s]

    return parsed_url
394755
public static String getProtocol(String url)
  {
    if(url == null) {
      return null;
    }
    int protocolSeparatorIndex = url.indexOf("://");
    if(protocolSeparatorIndex == -1) {
      return null;
    }
    return url.substring(0, protocolSeparatorIndex).toLowerCase();
  }
672703
public static EnumerationIter<URL> getResourceIter(String resource) {
		final Enumeration<URL> resources;
		try {
			resources = ClassLoaderUtil.getClassLoader().getResources(resource);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
		return new EnumerationIter<>(resources);
	}
428870
@Override
  protected ServiceRefAmp lookupService(String address)
  {
    String prefix = "cluster://";

    if (address.startsWith(prefix)) {
      int p = address.indexOf('/', prefix.length() + 1);
      
      if (p > 0) {
        String cluster = address.substring(prefix.length(), p);
        String path = address.substring(p);
    
        return lookupService(cluster, path);
      }
    }
    
    ServiceRefAmp serviceRef = services().service(address);
    
    return serviceRef;
  }
265560
public static ManifestVersion of(final URL url)
	{
		final ManifestVersion version = new ManifestVersion();
		if (url != null)
		{
			URLConnection urlConnection = null;
			try
			{
				urlConnection = url.openConnection();
				version.setLastModified(LocalDateTime.ofInstant(
					Instant.ofEpochMilli(urlConnection.getLastModified()), ZoneId.systemDefault()));
				version.setManifest(new Manifest(urlConnection.getInputStream()));
				version
					.setTitle(version.getManifestAttribute(Attributes.Name.IMPLEMENTATION_TITLE));
				version.setVersion(
					version.getManifestAttribute(Attributes.Name.IMPLEMENTATION_VERSION));
			}
			catch (final IOException e)
			{
				throw new RuntimeException("Error while try to load manifest file from " + url, e);
			}
		}
		return version;
	}
1139169
public static Environment of(@NonNull URL url) {
        try {
            return of(url.openStream());
        } catch (UnsupportedEncodingException e) {
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        return null;
    }
1117601
public static URL correct(final URL url) throws MalformedURLException {
        if (url == null) {
            throw new MalformedURLException("The url is null");
        }
        return new URL(correct(url.toString(), false));
    }