Determine if a uri is in asterisk-form according to
<a href="https://tools.ietf.org/html/rfc7230#section-5.3">rfc7230, 5.3</a>.
776486
public static boolean isAsteriskForm(URI uri) {
        return "*".equals(uri.getPath()) &&
                uri.getScheme() == null && uri.getSchemeSpecificPart() == null &&
                uri.getHost() == null && uri.getAuthority() == null && uri.getQuery() == null &&
                uri.getFragment() == null;
    }
355940
private static String rfc3986Conformance(String s) {
        assert s != null;

        String out;

        if (s == null) {
            return null;
        }

        try {
            out = URLEncoder.encode(s, UTF8_CHARSET).replace("+", "%20")
                    .replace("*", "%2A").replace("%7E", "~");
        } catch (UnsupportedEncodingException e) {
            out = s;
        }
        return out;
    }
1338215
def current_crumb?(path, pattern = :inclusive)
      return false unless request.get? || request.head?

      origin_path = URI.parser.unescape(path).force_encoding(Encoding::BINARY)

      request_uri = request.fullpath
      request_uri = URI.parser.unescape(request_uri)
      request_uri.force_encoding(Encoding::BINARY)

      # strip away trailing slash
      if origin_path.start_with?('/') && origin_path != '/'
        origin_path.chomp!('/')
        request_uri.chomp!('/')
      end

      if %r{^\w+://} =~ origin_path
        origin_path.chomp!('/')
        request_uri.insert(0, "#{request.protocol}#{request.host_with_port}")
      end

      case pattern
      when :inclusive
        !request_uri.match(/^#{Regexp.escape(origin_path)}(\/.*|\?.*)?$/).nil?
      when :exclusive
        !request_uri.match(/^#{Regexp.escape(origin_path)}\/?(\?.*)?$/).nil?
      when :exact
        request_uri == origin_path
      when :force
        true
      when Regexp
        !request_uri.match(pattern).nil?
      when Hash
        query_params = URI.encode_www_form(pattern)
        !request_uri.match(/^#{Regexp.escape(origin_path)}\/?(\?.*)?.*?#{query_params}.*$/).nil?
      else
        raise ArgumentError, "Unknown `:#{pattern}` match option!"
      end
    end
1251702
function isSameOrigin(a, b) {
  var urlA = parseURL(a);
  var urlB = parseURL(b);
  if (!urlA || !urlB) {
    return false;
  }
  if (urlA.origin === urlB.origin) {
    return true;
  }
  if (
    urlA.protocol === urlB.protocol &&
    urlA.hostname === urlB.hostname &&
    urlA.port === urlB.port
  ) {
    return true;
  }
  return false;
}
1221917
function checkUri(i) {
  const start = i;

  if (i >= tokensLength || tokens[i++].value !== 'url' ||
      i >= tokensLength || tokens[i].type !== TokenType.LeftParenthesis)
    return 0;

  return tokens[i].right - start + 1;
}
21096
protected function detectRequestUri()
	{
		// First we need to detect the URI scheme.
		if ($this->isSslConnection())
		{
			$scheme = 'https://';
		}
		else
		{
			$scheme = 'http://';
		}

		/*
		 * There are some differences in the way that Apache and IIS populate server environment variables.  To
		 * properly detect the requested URI we need to adjust our algorithm based on whether or not we are getting
		 * information from Apache or IIS.
		 */

		$phpSelf    = $this->input->server->getString('PHP_SELF', '');
		$requestUri = $this->input->server->getString('REQUEST_URI', '');

		// If PHP_SELF and REQUEST_URI are both populated then we will assume "Apache Mode".
		if (!empty($phpSelf) && !empty($requestUri))
		{
			// The URI is built from the HTTP_HOST and REQUEST_URI environment variables in an Apache environment.
			$uri = $scheme . $this->input->server->getString('HTTP_HOST') . $requestUri;
		}
		else
		{
			// If not in "Apache Mode" we will assume that we are in an IIS environment and proceed.
			// IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS
			$uri       = $scheme . $this->input->server->getString('HTTP_HOST') . $this->input->server->getString('SCRIPT_NAME');
			$queryHost = $this->input->server->getString('QUERY_STRING', '');

			// If the QUERY_STRING variable exists append it to the URI string.
			if (!empty($queryHost))
			{
				$uri .= '?' . $queryHost;
			}
		}

		return trim($uri);
	}
618151
def validate_redirect_uri(value):
    
    sch, netloc, path, par, query, fra = urlparse(value)
    if not (sch and netloc):
        raise InvalidRedirectURIError()
    if sch != 'https':
        if ':' in netloc:
            netloc, port = netloc.split(':', 1)
        if not (netloc in ('localhost', '127.0.0.1') and sch == 'http'):
            raise InsecureTransportError()
668962
def string_is_url(test_str):
    
    parsed = urlparse.urlparse(test_str)
    return parsed.scheme is not None and parsed.scheme != ''
597585
def __valid_url(cls, url):
        """"""
        bits = urlparse(url)
        return ((bits.scheme == "http" or bits.scheme == "https") and
                _PATTERN_URL_PART.match(bits.netloc) and
                _PATTERN_URL_PART.match(bits.path))
74056
def _uri(self, url):
        """"""
        if url and not url.startswith('/'):
            # Then this must be a proxy request.
            return url
        uri = "{0}://{1}{2}{3}".format(
            self._protocol,
            self.real_connection.host,
            self._port_postfix(),
            url,
        )
        return uri
442590
def validate_url(url):
    

    scheme = url.split('://')[0].lower()
    if scheme not in url_schemes:
        return False
    if not bool(url_regex.search(url)):
        return False
    return True
1103968
function current_word_is_url(tagged_sentence, i, parameter) {
              var is_url = false;
              if (tagged_sentence[i][0].indexOf(".") > -1) {
                // url if there are two contiguous alpha characters
                if (/[a-zA-Z]{2}/.test(tagged_sentence[i][0])) {
                  is_url = true;
                }
              }
              return((parameter === "YES") ? is_url : !is_url);
            }
89017
function checkLink(s) {
        return ((s.indexOf("http") === 0) || (s.indexOf(SLASH) === 0)) ? "<a href='" + s + "'>" + s + "</a>" : s;
    }
1098225
def geturi(self):
        
        scheme, authority, path, query, fragment = self

        # RFC 3986 5.3. Component Recomposition
        result = []
        if scheme is not None:
            result.extend([scheme, self.COLON])
        if authority is not None:
            result.extend([self.SLASH, self.SLASH, authority])
        result.append(path)
        if query is not None:
            result.extend([self.QUEST, query])
        if fragment is not None:
            result.extend([self.HASH, fragment])
        return self.EMPTY.join(result)
38673
protected function detectRequestUri()
	{
		// First we need to detect the URI scheme.
		if ($this->isSSLConnection())
		{
			$scheme = 'https://';
		}
		else
		{
			$scheme = 'http://';
		}

		/*
		 * There are some differences in the way that Apache and IIS populate server environment variables.  To
		 * properly detect the requested URI we need to adjust our algorithm based on whether or not we are getting
		 * information from Apache or IIS.
		 */

		// If PHP_SELF and REQUEST_URI are both populated then we will assume "Apache Mode".
		if (!empty($_SERVER['PHP_SELF']) && !empty($_SERVER['REQUEST_URI']))
		{
			// The URI is built from the HTTP_HOST and REQUEST_URI environment variables in an Apache environment.
			$uri = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
		}
		else
		// If not in "Apache Mode" we will assume that we are in an IIS environment and proceed.
		{
			// IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS
			$uri = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];

			// If the QUERY_STRING variable exists append it to the URI string.
			if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING']))
			{
				$uri .= '?' . $_SERVER['QUERY_STRING'];
			}
		}

		return trim($uri);
	}
1101798
def is_url(default_scheme='http', **kwargs):
    """"""
    def converter(value):
        if value is None:
            return value
        if '://' not in value and default_scheme:
            value = '://'.join((default_scheme, value.strip()))
        try:
            return uris.validate(value)
        except uris.ValidationError as e:
            raise Invalid(e.message)
    return converter
879324
function isUrl(string){
    if (typeof string !== 'string') {
      return false;
    }

    var match = string.match(protocolAndDomainRE);
    if (!match) {
      return false;
    }

    var everythingAfterProtocol = match[1];
    if (!everythingAfterProtocol) {
      return false;
    }

    return localhostDomainRE.test(everythingAfterProtocol) ||
        nonLocalhostDomainRE.test(everythingAfterProtocol);
  }