Get realm by URL.

@param sUrl URL string.
@return realm name or null.
@throws IOException transport exception.
@throws ModuleException ModuleException.
195515
private String getRealm(String sUrl) throws IOException, ModuleException
   {

      AuthorizationHandler ah = AuthorizationInfo.getAuthHandler();

      try
      {
         URL url = new URL(sUrl);
         HTTPConnection connection = new HTTPConnection(url);
         connection.removeModule(CookieModule.class);
         AuthorizationInfo.setAuthHandler(null);

         HTTPResponse resp = connection.Get(url.getFile());

         String authHeader = resp.getHeader("WWW-Authenticate");
         if (authHeader == null)
         {
            return null;
         }

         String realm = authHeader.split("=")[1];
         realm = realm.substring(1, realm.length() - 1);

         return realm;

      }
      finally
      {
         AuthorizationInfo.setAuthHandler(ah);
      }
   }
811592
function getDomainFromURL(url) {
  if (url) {
    let domain;
    // find & remove protocol (http, ftp, etc.) and get domain
    if (url.indexOf('://') > -1) {
      domain = url.split('/')[2];
    } else {
      domain = url.split('/');
    }

    // find & remove port number
    domain = domain.split(':');

    return domain;
  }
  return null;
}
1049919
public function site_url($sUrl = '', $bForceSecure = false)
    {
        //  If an explicit URL is passed in, then leave it be
        if (preg_match('/^(http|https|ftp|mailto)\:/', $sUrl)) {
            return $sUrl;
        }

        $sUrl = parent::site_url($sUrl);

        //  If the URL begins with a slash then attempt to guess the host using $_SERVER
        if (preg_match('/^\//', $sUrl) && !empty($_SERVER['HTTP_HOST'])) {
            $sProtocol = !empty($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'http';
            $sUrl      = $sProtocol . '://' . $_SERVER['HTTP_HOST'] . $sUrl;
        }

        if ($bForceSecure || Functions::isPageSecure()) {
            $sUrl = preg_replace('#^' . BASE_URL . '#', SECURE_BASE_URL, $sUrl);
        }

        return $sUrl;
    }
1079129
public TLSARecord getTLSARecord(URL url) {

        String recordValue;

        int port = url.getPort();
        if (port == -1) {
            port = url.getDefaultPort();
        }
        String tlsaRecordName = String.format("_%s._tcp.%s", port, DNSUtil.ensureDot(url.getHost()));
        try {
            recordValue = this.dnssecResolver.resolve(tlsaRecordName, Type.TLSA);
        } catch (DNSSECException e) {
            return null;
        }

        if (recordValue.equals("")) return null;

        // Process TLSA Record
        String[] tlsaValues = recordValue.split(" ");
        if (tlsaValues.length != 4) return null;
        try {
            return new TLSARecord(
                    new Name(tlsaRecordName),
                    DClass.IN,
                    0,
                    Integer.parseInt(tlsaValues[0]),
                    Integer.parseInt(tlsaValues[1]),
                    Integer.parseInt(tlsaValues[2]),
                    BaseEncoding.base16().decode(tlsaValues[3])
            );
        } catch (TextParseException e) {
            return null;
        }
    }
504260
public function processSeoUrl($sUrl)
    {
        if (!$this->isAdmin()) {
            $sUrl = $this->getSession()->processUrl($this->appendUrl($sUrl, $this->getAddUrlParams()));
        }

        $sUrl = $this->cleanUrlParams($sUrl);

        return $this->rightTrimAmp($sUrl);
    }
120199
function getUrl(remoteName){
    const gitInfo = getGitInfo();
    return remoteName ? getRepoRemoteUrl(gitInfo, remoteName) : getAllRemotesUrls(gitInfo);
}
525255
private String getRealmNameOrFirstBest(Root root) {
        String value = null;
        value = getRealmName(root);
        if (value == null) {
            try {
                value = getRealmName();
            } catch (Exception e) {
                // leave realm at null
            }
        }
        return value;
    }
742472
public static RemoteRepository remoteRepositoryFromUrl(String url) throws MalformedURLException {
        URL parsedUrl = new URL(url);

        StringBuffer id = new StringBuffer(parsedUrl.getHost());
        String path = parsedUrl.getPath();
        if (path.length() > 0) {
            path = path.replaceFirst("/", "").replaceAll("/", "-").replaceAll(":", "-");
            id.append("-");
            id.append(path);
        }

        if (parsedUrl.getPort() > -1) {
            id.append("-");
            id.append(parsedUrl.getPort());
        }

        return new RemoteRepository(id.toString(), "default", url);
    }
1313722
public static boolean isValid (@Nullable final String sURL)
  {
    if (StringHelper.hasNoText (sURL))
      return false;

    final String sUnifiedURL = getUnifiedURL (sURL);
    return PATTERN.matcher (sUnifiedURL).matches ();
  }
329888
protected HttpEntity get(HttpClient httpClient, String url) throws IOException {
        logger.debug("Doing GET request on " + url);
        HttpGet get = new HttpGet(url);
        try {
            HttpResponse response = execute(httpClient, get);
            int responseCode = response.getStatusLine().getStatusCode();
            if (responseCode == 404) {
                return null;
            } else if (responseCode != 200) {
                throw new RuntimeException("Unexpected response code (" + responseCode + ") getting " + url);
            }
            return response.getEntity();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
881880
public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
        try {
            if (com.google.api.ads.adwords.axis.v201809.cm.OfflineCallConversionFeedServiceInterface.class.isAssignableFrom(serviceEndpointInterface)) {
                com.google.api.ads.adwords.axis.v201809.cm.OfflineCallConversionFeedServiceSoapBindingStub _stub = new com.google.api.ads.adwords.axis.v201809.cm.OfflineCallConversionFeedServiceSoapBindingStub(new java.net.URL(OfflineCallConversionFeedServiceInterfacePort_address), this);
                _stub.setPortName(getOfflineCallConversionFeedServiceInterfacePortWSDDServiceName());
                return _stub;
            }
        }
        catch (java.lang.Throwable t) {
            throw new javax.xml.rpc.ServiceException(t);
        }
        throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface:  " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName()));
    }
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();
  }
832746
function(sUrl) {

				// local resources are registered with "./" => we remove the leading "./"!
				// (code location for this: sap/ui/Global.js:sap.ui.localResources)
				// we by default normalize all relative URLs for a common base
				var oUri = URI(sUrl || "./");
				if (oUri.is("relative")) { //(sUrl.match(/^\.\/|\..\//g)) {
					oUri = oUri.absoluteTo(sLocation);
				}
				//return oUri.normalize().toString();
				// prevent to normalize the search and hash to avoid "+" in the search string
				// because for search strings the space will be normalized as "+"
				return oUri.normalizeProtocol().normalizeHostname().normalizePort().normalizePath().toString();

			}
1023198
@Override
    public String getProxyURL() {
        try {
            if (hasProperty(PROXY_FOR)) {
                return getProperty(PROXY_FOR).getString();
            }
            return null;
        } catch (final RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
    }
336183
function _getHostByPeerUrl( sUrl )
{
	let arrMatches;

	//
	//	this regex will match wss://xxx and ws://xxx
	//
	arrMatches = sUrl.match( /^wss?:\/\/(.*)$/i );
	if ( Array.isArray( arrMatches ) && arrMatches.length >= 1 )
	{
		sUrl = arrMatches[ 1 ];
	}

	//	...
	arrMatches	= sUrl.match( /^(.*?)[:\/]/ );
	return ( Array.isArray( arrMatches ) && arrMatches.length >= 1 ) ? arrMatches[ 1 ] : sUrl;
}
866682
function(sUrl) {
			for (var i = 0; i < this.aEntriesUrlReplace.length; i++) {
				var oEntry = this.aEntriesUrlReplace[i];
				if (oEntry.regex instanceof RegExp && oEntry.value !== undefined) {
					sUrl = sUrl.replace(oEntry.regex, oEntry.value);
				} else {
					this.oLog.warning(sModuleName + " - Invalid regular expression for url replace.");
				}
			}
			return sUrl;
		}
573301
@Nullable
  public String getWithoutProtocol (@Nullable final String sURL)
  {
    final IURLProtocol aProtocol = getProtocol (sURL);
    return aProtocol == null ? sURL : sURL.substring (aProtocol.getProtocol ().length ());
  }