@param IUrl $url
@param array $protocols

@return bool
167906
public function compareUrlToProtocols(IUrl $url, array $protocols) {
        if (count($protocols) == 0) {
            return true;
        }

        return array_contains($protocols, $url->getProtocol());
    }
776241
public function build($method, Url $url, array $headers)
    {
        if (($scheme = self::isAllowedScheme((string)$url->scheme())) === false) {
            throw new UnknownProtocolException(sprintf(
                "You can't request a transfer on unsupported protocol '%s'!",
                $url->scheme()
            ));
        }

        $scheme = ucfirst($scheme);
        $name = __NAMESPACE__.'\\'.$scheme.'\\'.ucfirst(strtolower($method));
        if (!class_exists($name)) {
            throw new InvalidArgumentException('Method given is not a valid request: '.$method);
        }

        $configurationClass = '\Bee4\Transport\Configuration\\'.$scheme.'Configuration';
        $request = new $name(
            $url,
            $headers,
            new $configurationClass(
                $this->configuration!==null?$this->configuration->toArray():[]
            )
        );

        return $request;
    }
1338516
public static function GetQueryStringFromKeyVals(string $url, array $keyVals)
    {
        if ($url == NULL) {
            throw new \InvalidArgumentException('url');
        }

        if ($keyVals == NULL) {
            throw new \InvalidArgumentException('keyVals');
        }

        $anchorIndex = strpos($url, '#');
        $resultUri = $url;
        $anchorText = "";
        if ($anchorIndex !== FALSE) {
            $anchorText = substr($url, $anchorIndex);
            $resultUri = substr($url, 0, $anchorIndex);
        }

        $queryIndex = strpos($resultUri, '?');
        $hasQuery = $queryIndex !== FALSE;

        $sb = '';
        $sb .= $resultUri;
        foreach ($keyVals as $keyKey => $keyVal) {
            $sb .= $hasQuery ? '&' : '?';
            $sb .= urlencode($keyKey);
            $sb .= '=';
            $sb .= urlencode($keyVal);
            $hasQuery = TRUE;
        }

        $sb .= $anchorText;

        return $sb;
    }
952068
public function compareUrlToTLDs(IUrl $url, array $tlds) {
        if (count($tlds) == 0) {
            return true;
        }

        return array_contains($tlds, $url->getTLD());
    }
544323
public static function unauthorized(string $uri, string $protocol = Protocol::HTTP): self
    {
        return new static(sprintf('Unauthorized: `%s`', $uri), $protocol, 401);
    }
14984
public function createRoute(IRouter $routes, string $url): void
	{
		$this->createPageRoute($routes, $url);
		$this->createDefaultPageRoutes($routes, $url);
	}
178680
public function toUrl($url, $parameters)
	{
		foreach ($parameters as $key => $value)
		{
			if (\is_array($value))
			{
				foreach ($value as $k => $v)
				{
					if (strpos($url, '?') === false)
					{
						$url .= '?' . $key . '=' . $v;
					}
					else
					{
						$url .= '&' . $key . '=' . $v;
					}
				}
			}
			else
			{
				if (strpos($value, ' ') !== false)
				{
					$value = $this->safeEncode($value);
				}

				if (strpos($url, '?') === false)
				{
					$url .= '?' . $key . '=' . $value;
				}
				else
				{
					$url .= '&' . $key . '=' . $value;
				}
			}
		}

		return $url;
	}
1167776
protected function doesUrlMatchToAtLeastOnePattern($url, array $patterns)
    {
        foreach ($patterns as $pattern) {
            $regex = '|' . $pattern . '|';
            $this->verbose(
                "Checking url '" . $url . "' with regex '" . $regex . "' -> ",
                OutputInterface::VERBOSITY_VERBOSE
            );
            if (preg_match($regex, $url)) {
                $this->verbose("MATCHED\n", OutputInterface::VERBOSITY_VERBOSE);
                return true;
            } else {
                $this->verbose("NOT matched\n", OutputInterface::VERBOSITY_VERBOSE);
            }
        }
        return false;
    }
1196874
protected function matchNestedRouters(
        $method,
        IUrl $url,
        array &$exceptions,
        IRoute $route = null
    ) {
        foreach ($this->getNestedRouters() as $router) {
            $match = $router->matchRouter($method, $url, $exceptions, $route);

            if ($match !== null) {
                $route = $match;
                break;
            }
        }

        return $route;
    }
781858
public static function site($uri = '', $protocol = null, $index = false)
    {
        // 关闭可能的计划，主机，端口，用户和其他匹配到的部分
        $path = preg_replace('~^[-a-z0-9+.]++://[^/]++/?~', '', trim($uri, '/'));

        if (preg_match('/[^\x00-\x7F]/S', $path))
        {
            // 编码所有非ASCII字符，RFC 1738标准
            $path = preg_replace_callback('~([^/]+)~', 'rawurlencode', $path);
        }

        return self::base($protocol, $index) . $path;
    }
767093
public function matches($url, array $annotations)
	{
		foreach ( $annotations as $annotation ) {
			if ( $this->matchComponent($annotation, $url) ) {
				return true;
			}
		}

		return false;
	}
336994
function (url, protocol, hostname, port) {
                var match = text.xdRegExp.exec(url),
                    uProtocol, uHostName, uPort;
                if (!match) {
                    return true;
                }
                uProtocol = match[2];
                uHostName = match[3];

                uHostName = uHostName.split(':');
                uPort = uHostName[1];
                uHostName = uHostName[0];

                return (!uProtocol || uProtocol === protocol) &&
                       (!uHostName || uHostName === hostname) &&
                       ((!uPort && !uHostName) || uPort === port);
            }
870290
public static function register($protocol, $flags = 0)
  {
    $wrappers = stream_get_wrappers();
    if (in_array($protocol, $wrappers)) {
      throw new Wrapper_Exception(
        "Protocol '$protocol' has been already registered"
      );
    }
    $className = get_called_class();

    return stream_wrapper_register($protocol, $className, $flags);
  }
1201169
public function resolve($url)
    {
        $parts = parse_url($url);
        $parameters = [];
        $parameters['transport'] = isset($parts['scheme']) ? $parts['scheme'] : null;
        $parameters['encryption'] = null;

        // check for schemes such as 'ssl+smtp' and 'smtp+tls'
        if (strpos($parameters['transport'], '+') !== false) {
            $transports = explode('+', $parameters['transport']);
            if (count($transports) !== 2) {
                throw new \LogicException("Invalid transport in mailer url '$url'.");
            }

            if (in_array($transports[0], self::$valid_schemes)) {
                $parameters['transport'] = $transports[0];
                $parameters['encryption'] = $transports[1];
            } else {
                $parameters['transport'] = $transports[1];
                $parameters['encryption'] = $transports[0];
            }
        }

        $parameters['auth_mode'] = null;
        if (isset($parts['query'])) {
            parse_str($parts['query'], $query);

            // don't overwrite transport
            if (isset($query['transport'])) {
                unset($query['transport']);
            }

            // don't overwrite encryption if set
            if (isset($query['encryption']) && $parameters['encryption'] !== null) {
                unset($query['encryption']);
            }
            $parameters = array_merge($parameters, $query);
        }

        // extra parameters
        $parameters['host'] = isset($parts['host']) ? $parts['host'] : null;
        $parameters['port'] = isset($parts['port']) ? $parts['port'] : false;
        $parameters['user'] = isset($parts['user']) ? $parts['user'] : null;
        $parameters['password'] = isset($parts['pass']) ? $parts['pass'] : null;

        // some validation
        if ($parameters['transport'] !== null && !in_array($parameters['transport'], self::$valid_schemes)) {
            throw new \LogicException("Invalid transport scheme '{$parameters['transport']}'.");
        }

        if ($parameters['encryption'] !== null && !in_array($parameters['encryption'], self::$valid_encryption)) {
            throw new \LogicException("Invalid encryption method '{$parameters['encryption']}'.");
        }

        if ($parameters['auth_mode'] !== null && !in_array($parameters['auth_mode'], self::$valid_auth_modes)) {
            throw new \LogicException("Invalid auth_mode '{$parameters['auth_mode']}'.");
        }

        // some extra checks for specific cases
        if ($parameters['transport'] === null) {
            if ($url === 'sendmail://' || $url === 'sendmail') {
                $parameters['transport'] = 'sendmail';
            } else if ($url === 'mail://' || $url === 'mail') {
                $parameters['transport'] = 'mail';
            } else if (strpos($url, 'gmail://') === 0) {
                $userpass = substr($url, 8);
                $userpassparts = explode(':', $userpass, 2);
                if (count($userpassparts) === 2) {
                    $parameters['transport'] = 'gmail';
                    $parameters['user'] = $userpassparts[0];
                    $parameters['password'] = $userpassparts[1];
                }
            } else {
                throw new \LogicException("Invalid url specified '{$url}'");
            }
        }

        // disable transport if requested
        if ($parameters['transport'] === 'none' || $parameters['transport'] === 'null') {
            $parameters['transport'] = null;
        }

        return $parameters;
    }
77573
public static function isValidUrl($url) {
		require_once(PATH_typo3 . 'contrib/idna/idna_convert.class.php');
		$IDN = new idna_convert(array('idn_version' => 2008));

		return (filter_var($IDN->encode($url), FILTER_VALIDATE_URL) !== FALSE);
	}
1166140
public function matchUrl(RequestInterface $request, array $maps)
    {
        $matched = [];

        $uri = (string)$request->getUri();

        /** @var RequestMap $map */
        foreach ($maps as $map) {
            if ((string)$map->getRequest()->getUri() === $uri) {
                $matched[] = $map;
            }
        }

        return $matched;
    }
339615
public function handle($sender, ProtocolInterface $protocol, $flags, callable $success = null, callable $failure = null, callable $cancel = null, $timeout = 0.0)
    {
        $callback = $this->handler;
        $callback($sender, $protocol, $flags, $success, $failure, $cancel, $timeout);

        if ($this->limit > 0)
        {
            $this->limit--;
            if ($this->limit === 0)
            {
                $this->cancel();
            }
        }

        return $this->propagate;
    }