@param string $url

@return string|null
@throws InvalidArgumentException
12248
public static function getProtocol($url)
    {
        $urlInfo = static::info($url);

        return ArrayHelper::get($urlInfo, 'protocol', null, true);
    }
304042
private function get($url)
    {
        try {
            $result = $this->fileHelper->getContents(
                $url,
                $this->config->get('concrete.marektplace.request_timeout'));
        } catch (TimeoutException $e) {
            // Catch a timeout
            $this->connectionError = self::E_CONNECTION_TIMEOUT;

            return null;
        } catch (Exception $e) {
            $this->connectionError = self::E_GENERAL_CONNECTION_ERROR;

            return null;
        }

        return $result ?: null;
    }
988540
static public function rUrl($url)
    {
        $module = null;
        if (strpos($url, 'http') !== 0 && ($pos = strpos($url, ':')) !== false) {    // 1. "x:a/b" module or xUrl
            $module = trim(substr($url, 0, $pos), '/');
            $url   = trim(substr($url, $pos + 1), '/');
        }
        
        if (strpos($url, 'http') === 0) {
            $url = str_replace(static::url($module . ':'), '', $url);
        }
        
        return trim($url, '/');
    }
696375
public function setUrl($url)
    {
        if (strlen($url) == 0) {
            throw new \InvalidArgumentException(sprintf('Enclosure URL should not be empty'));
        }

        $this->url = $url;

        return $this;
    }
791663
public function matchUrl($url)
    {
        $url = '/' . ltrim($url, '/');
        $url = $this->sanitizeUrl($url);

        if ($url && $route = $this->matchUrlDirectly($url)) {
            return $route;
        }
        if ($url && $route = $this->matchUrlWithParameters($url)) {
            return $route;
        }
        return null;
    }
90346
private static function parse($url)
    {
        $enc_url = preg_replace_callback(
            '%[^:/@?&=#]+%usD',
            function ($matches) {
                return rawurlencode($matches[0]);
            },
            $url
        );

        $parts = parse_url($enc_url);

        if ($parts === false) {
            throw new \InvalidArgumentException('Malformed URL: ' . $url);
        }

        if (!empty($parts['scheme']) && !in_array($parts['scheme'], ['http', 'https', 'data'])) {
            throw new \InvalidArgumentException(sprintf('Invalid URL scheme: "%s"', $parts['scheme']));
        }

        foreach ($parts as $name => $value) {
            $parts[$name] = rawurldecode($value);
        }
        return $parts;
    }
36621
public function parseUrl($url) : array
    {
        $url = (string) $url;

        $parsedUrl = $this->doParseUrl($url);

        if ($parsedUrl === []) {
            throw new InvalidArgumentException(sprintf('Invalid url %s', $url));
        }

        $parsedUrl = array_merge(self::$defaultParts, $parsedUrl);

        if (isset($parsedUrl['host'])) {
            $parsedUrl['canonical'] = implode('.', array_reverse(explode('.', $parsedUrl['host']))) . ($parsedUrl['path'] ?? '') . (isset($parsedUrl['query']) ? '?' . $parsedUrl['query'] : '');

            $parsedUrl['resource'] = $parsedUrl['path'] ?? '';

            if (isset($parsedUrl['query'])) {
                $parsedUrl['resource'] .= '?' . $parsedUrl['query'];
            }
        }

        return $parsedUrl;
    }
303390
function formatUrl($url)
    {
        if (! $this->isUrl($url)) {
            return null;
        }
        $url = trim($url);
        $url = str_replace(' ', '+', $url);
        $parse = parse_url($url);
        strtolower($parse['scheme']);
        strtolower($parse['host']);
        return $this->buildUrl($parse);
    }
258360
public static function tryParse(string $url): ?UrlInterface
    {
        if (!self::myParse(null, $url, $scheme, $host, $port, $path, $queryString, $fragment)) {
            return null;
        }

        return new self($scheme, $host, $port, $path, $queryString, $fragment);
    }
354059
protected function getValidContentUrl($url)
    {
        if (null === $this->redirectApi && false !== $redirectApi = $this->cache->read('redirect-api')) {
            $this->redirectApi = $redirectApi;
        }

        if (\is_string($this->redirectApi) && 0 === strpos($url, $this->getRepositoryApiUrl())) {
            $url = $this->redirectApi.substr($url, \strlen($this->getRepositoryApiUrl()));
        }

        return $url;
    }
355327
public function setUrl($url)
    {
      if(!is_string($url) && strlen(trim($url)) == 0)
        throw new InvalidArgumentException(__METHOD__ . '; Invalid url, must be a non empty string');

      $this->url = $url;
    }
336467
public function urlToFormParameters($url)
    {
        $query = parse_url($url, PHP_URL_QUERY);
        $vars = array();
        parse_str($query, $vars);
        return $this->valuesToFormParameters($vars, null);
    }
347777
public static function getDomainFromURL($url)
	{
		$url = str_replace(self::getProtocolFromURL($url) . '://', '', $url);
		
		return explode('/', $url)[0];
	}
803643
public function webalizeUrl(string $url) : string
    {
        $regex = PageRepository::URL_REGEX;

        if (preg_match("/{$regex}/", $url) === FALSE)
        {
            throw new InvalidArgumentException('Url contains wrong characters. Allowed characters are \'a-z, 0-9, slash, dash\'');
        }

        $url = preg_replace('~-{2,}~', '-', $url);
        $url = preg_replace('~/{2,}~', '/', $url);
        $url = trim($url, '-/');

        return $url;
    }
1172699
public static function getAbsoluteUrl($url = null)
    {
        if (is_null($url)) {
            return '';
        }
        if (self::isUrl($url)) {
            return $url;
        }
        $url            = '/'.self::resolvePath($url);
        $current_url    = self::getRequestUrl(true, true);
        $curr           = substr($current_url, 0, strrpos($current_url, '/') );
        return $curr.$url;
    }
1008756
public function parse($url)
    {
        foreach ($this->map as $pattern) {
            $pattern = $this->compile($pattern);
            if (preg_match($pattern, $url, $match)) {
                // remove numeric keys
                foreach ($match as $key => $value) {
                    if (is_numeric($key)) {
                        unset($match[$key]);
                    }
                }

                return $match;
            }
        }

        throw new Exceptions\InvalidArgumentException("URL '$url' did not match any route.");
    }
1082149
public static function segmentUrl($url = null)
    {
        if (!is_null($url) && !empty($url)) {
            $url = $url;
        } else {
            $url = self::requestInstance()->getRequestUrl();
        }

        return explode('/', trim($url, '/'));
    }