@param string $url

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

        return ArrayHelper::get($urlInfo, 'domain', null, true);
    }
1357417
protected function set($url)
    {
        $parts = parse_url($url);
        if (!$parts) {
            throw new \InvalidArgumentException('URL malformed');
        }

        $this->scheme   = isset($parts['scheme']) ? strtolower($parts['scheme']) : '';
        $this->username = $parts['user'] ?? '';
        $this->password = $parts['pass'] ?? '';
        $this->host     = isset($parts['host']) ? strtolower($parts['host']) : '';
        $this->port     = isset($parts['port']) ? intval($parts['port']) : null;
        $this->path     = $parts['path'] ?? '';
        $this->query    = $parts['query'] ?? '';
        $this->fragment = $parts['fragment'] ?? '';
    }
1372912
public function setUrl($url)
    {
        if (!is_null($url) && !$url instanceof KHttpUrl) {
            throw new InvalidArgumentException('Invalid url type.');
        }

        $this->url = $url;
        return $this;
    }
886862
public static function getParamFromLink($url, $paramName)
    {
        if (!$url) {
            throw new \InvalidArgumentException('url');
        }

        if (!$paramName) {
            throw new \InvalidArgumentException('paramName');
        }

        $parts = parse_url(html_entity_decode($url));
        if (isset($parts)) {
            parse_str($parts['query'], $query);
            if (array_key_exists($paramName, $query)) {
                return $query[$paramName];
            }
        }

        return null;
    }
250569
protected static function resolveUrl($url)
    {
        $url = trim($url);
        if (strlen($url)) {
            if (preg_match('%^https?\:\/\/%', $url)) {
                return $url;
            }
            $absScript = GeneralUtility::getFileAbsFileName($url);
            if (is_file($absScript)) {
                return substr($absScript, strlen(PATH_site));
            }
        }

        return null;
    }
790140
public static function getFromUrl($url)
    {
        // check is valid url
        if (!filter_var($url, FILTER_VALIDATE_URL) || !function_exists('curl_init')) {
            return null;
        }

        // initialize curl & set required options and target url
        $curl = \curl_init();
        \curl_setopt($curl, CURLOPT_URL, $url);
        if (Str::startsWith('https', $url)) {
            \curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
            \curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        }
        \curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        \curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
        \curl_setopt($curl, CURLOPT_HEADER, 0);
        \curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)');
        \curl_setopt($curl, CURLOPT_FAILONERROR, true);
        \curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
        \curl_setopt($curl, CURLOPT_AUTOREFERER, true);
        \curl_setopt($curl, CURLOPT_TIMEOUT, 10);
        $content = \curl_exec($curl);
        \curl_close($curl);

        return $content;
    }
1099712
public function urlQuerystring($url)
    {
        $querystring = $this->querystring();
        if (isset($this->timestamp) && !Utils::contains($querystring, $this->timestamp)) {
            $querystring = empty($querystring) ? ('?' . $this->timestamp) : ($querystring . '&' . $this->timestamp);
        }

        return ltrim($url . $querystring . $this->urlHash(), '/');
    }
99661
public static function params($url) {
        $path  = explode('?', $url)[0];
        $query = parse_url($url, PHP_URL_QUERY);
        if ($query) {
            return site_url($path, $query);
        } else {
            return false;
        }
    }
87464
public function embedCodeFor(string $url)
    {
        if (!$parsedUrl = $this->embedder->parseUrl($url)) {
            return null;
        }

        return $parsedUrl->getEmbedCode();
    }
336467
public function urlToFormParameters($url)
    {
        $query = parse_url($url, PHP_URL_QUERY);
        $vars = array();
        parse_str($query, $vars);
        return $this->valuesToFormParameters($vars, null);
    }
486994
public static function multibyteParseUrl($url)
    {
        $enc_url = preg_replace_callback(
            '%[^:/@?&=#]+%usD',
            function ($matches) {
                return urlencode($matches[0]);
            },
            $url
        );

        $parts = parse_url($enc_url);

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

        foreach($parts as $name => $value) {
            $parts[$name] = urldecode($value);
        }

        return $parts;
    }
662180
public static function sanitizeUrl($url)
    {
        $url = trim($url);

        if (!$url) {
            return null;
        }

        if (!preg_match("/^https?:\/\//i", $url)) {
            $url = "http://" . $url;
        }

        return self::sanitizeString($url);
    }
275431
public function validateUrl($url)
    {
        if ('' === $url) {
            return $this;
        }

        if (!is_string($url) || strlen($url) > 2000) {
            throw new InvalidArgumentException(
                'URL must be a string of at most 2,000 characters',
                400
            );
        }

        return $this;
    }
81774
private function getUrl(string $url): string
    {
        $urlParts = parse_url($url);

        if ($urlParts === false) {
            throw new \ParseError("Could not parse URL: $url");
        }

        if ($this->baseUrl !== null && ! isset($urlParts['host'])) {
            $url = $this->baseUrl . '/' . ltrim($url, '/');
        }

        return $url;
    }
947181
protected function getMessage(string $url): ?string
    {
        $response = wp_remote_get($url);
        $responseCode = wp_remote_retrieve_response_code($response);

        if (! is_int($responseCode)) {
            return 'Unable to reach ' . $url;
        }

        return ($this->expectedStatusCode === $responseCode)
            ? null
            : $url . ' returns ' . $responseCode;
    }
783931
protected function parseUrl($url)
    {
        if ($parsed = parse_url($url)) {
            return $this->addPassword($parsed);
        }

        // A second try for not file:// schemes which does support absolute
        // paths (like sqlite:///)

        // Cut the scheme by hand
        $parts = explode(':', $url, 2);

        if (count($parts) != 2 || strlen($parts[0]) > 24) {
            throw new InvalidArgumentException("Unparseable url $url");
        }

        // Now cheat parse_url by giving it a file url
        if (!$parsed = parse_url('file:'.$parts[1])) {
            throw new InvalidArgumentException("Unparseable url $url");
        }

        $parsed['scheme'] = $parts[0];

        return $this->addPassword($parsed);
    }
648192
public function toAbsoluteUrl(Url $root = null)
    {
        $root = $this->getRoot() ?: $root;
        if (!$root->isUrlAbsolute()) {
            throw new \InvalidArgumentException();
        }
        if (!$this->isUrlAbsolute()) {
            $this->setScheme($root->getScheme());
            $this->setHost($root->getHost());
            if (!$this->isPathAbsolute()) {
                $path = $root->getPath();
                $path = substr($path, 0, strrpos($path, '/') + 1);
                $this->setPath($path . $this->getPath());
            }
        }
        return $this;
    }