Expand the given url

@param  string  $url
@throws InvalidResponseException
@return string
359590
public function expand($url)
    {
        try {
            return $this->driver->expand($url);
        } catch (BadResponseException $e) {
            throw new Exceptions\InvalidResponseException($e->getMessage());
        } catch (InvalidApiResponseException $e) {
            throw new Exceptions\InvalidResponseException($e->getMessage());
        }
    }
1275167
private function executeQuery(string $url): \stdClass
    {
        $content = $this->getUrlContents($url);
        $json = json_decode($content);
        // API error
        if (!isset($json)) {
            throw InvalidServerResponse::create($url);
        }

        return $json;
    }
173732
private function convertSshUrl($url, $username_suffix = '')
    {
        $parsed = parse_url($url);
        if (!$parsed) {
            throw new \InvalidArgumentException('Invalid URL: ' . $url);
        }

        return $parsed['user'] . $username_suffix . '@' . $parsed['host'];
    }
1317925
static function parse(string $url, ?int $preferredFormat = self::ABSOLUTE)
    {
        $components = parse_url($url);

        if ($components === false) {
            throw new InvalidUrlException(sprintf('The given URL "%s" is invalid', $url));
        }

        $query = [];

        if (isset($components['query'])) {
            parse_str($components['query'], $query);
        }

        return new static(
            $components['scheme'] ?? null,
            $components['host'] ?? null,
            $components['port'] ?? null,
            $components['path'] ?? '',
            $query,
            $components['fragment'] ?? null,
            $preferredFormat
        );
    }
1095489
public static function explode_url($url)
    {
        $protocol = "";
        $host = "";
        $path = "";
        $file = "";

        $arr = parse_url($url);
        if ( isset($arr["scheme"]) ) {
            $arr["scheme"] = mb_strtolower($arr["scheme"]);
        }

        // Exclude windows drive letters...
        if (isset($arr["scheme"]) && $arr["scheme"] !== "file" && strlen($arr["scheme"]) > 1) {
            $protocol = $arr["scheme"] . "://";

            if (isset($arr["user"])) {
                $host .= $arr["user"];

                if (isset($arr["pass"])) {
                    $host .= ":" . $arr["pass"];
                }

                $host .= "@";
            }

            if (isset($arr["host"])) {
                $host .= $arr["host"];
            }

            if (isset($arr["port"])) {
                $host .= ":" . $arr["port"];
            }

            if (isset($arr["path"]) && $arr["path"] !== "") {
                // Do we have a trailing slash?
                if ($arr["path"][mb_strlen($arr["path"]) - 1] === "/") {
                    $path = $arr["path"];
                    $file = "";
                } else {
                    $path = rtrim(dirname($arr["path"]), '/\\') . "/";
                    $file = basename($arr["path"]);
                }
            }

            if (isset($arr["query"])) {
                $file .= "?" . $arr["query"];
            }

            if (isset($arr["fragment"])) {
                $file .= "#" . $arr["fragment"];
            }

        } else {

            $i = mb_stripos($url, "file://");
            if ($i !== false) {
                $url = mb_substr($url, $i + 7);
            }

            $protocol = ""; // "file://"; ? why doesn't this work... It's because of
            // network filenames like //COMPU/SHARENAME

            $host = ""; // localhost, really
            $file = basename($url);

            $path = dirname($url);

            // Check that the path exists
            if ($path !== false) {
                $path .= '/';

            } else {
                // generate a url to access the file if no real path found.
                $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';

                $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n");

                if (substr($arr["path"], 0, 1) === '/') {
                    $path = dirname($arr["path"]);
                } else {
                    $path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"];
                }
            }
        }

        $ret = array($protocol, $host, $path, $file,
            "protocol" => $protocol,
            "host" => $host,
            "path" => $path,
            "file" => $file);
        return $ret;
    }
454954
public static function setApiUrl($url)
    {
        $apiUrl = filter_var($url, FILTER_VALIDATE_URL);

        if (!$apiUrl) {
            throw new Exception\InvalidArgumentException(
                'API URL should be a valid url'
            );
        }

        self::$apiUrl = rtrim($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;
    }
781315
protected function parse($url) {
        // set the download file url
        $this->url = $url;

        // parse the url, to remove possible query parameters, otherwise it is not possible to fetch the extension
        $urlParsed = parse_url($url);

        // get the path info of the given name
        $pathinfo = pathinfo($urlParsed['path']);

        // get the base file name
        $this->nameOriginal = $pathinfo['filename'];

        // set the file name
        $this->extension = $pathinfo['extension'];

        // done, return the instance of this, to make chaining possible
        return $this;
    }
760777
protected function splitUrl($url)
    {
        $path = parse_url(trim($url, '/'), PHP_URL_PATH);
        return $path ? explode('/', $path) : array();
    }
1157509
public function initFromUrl($url)
    {
        
        $options = [
            'http' => [
                'method'=>"GET",
                'header'=>"Accept-language: en\r\n".
                "User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2\r\n"
          ]
        ];
        
        $context  = stream_context_create($options);
        

        if ($data = @file_get_contents($url, false, $context)) {
            return $this->initFromBinary($data);
        }

        throw new \Intervention\Image\Exception\NotReadableException(
            "Unable to init from given url (".$url.")."
        );
    }
890474
public static function get(string $url)
	{
		$ch = curl_init($url);

		curl_setopt_array(
			$ch,
			[
				CURLOPT_HEADER         => 1,
				CURLOPT_RETURNTRANSFER => 1,
				CURLOPT_SSL_VERIFYPEER => 0,
			]
		);

		$response = curl_exec($ch);

		$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
		if ($responseCode != 200) {
			throw new HttpException('Could not reach ' . $url, $responseCode);
		}
		$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
		$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);

		curl_close($ch);

		$response = substr($response, $headerSize);

		if (is_null($response)) {
			throw new HttpException('You are exceeding the API request limit.  Please wait longer between requests.', 400);
		}

		if(stripos($contentType, 'application/json') !== false) {
			$response = json_decode($response, true);
		}

		return $response;
	}
1346114
public function url(string $url) : RequestBuilder
    {
        $this->url = $url;

        // Also store the query parameters if present
        $queryString = parse_url($this->url, PHP_URL_QUERY);
        parse_str($queryString, $query);
        if ($query) {
            $this->query = $query;
        }

        return $this;
    }
31363
protected function getRemoteContent($url)
    {
        $response = (new Client())
            ->createRequest()
            ->setMethod('GET')
            ->setUrl($url)
            ->send();
        if (!$response->isOk) {
            throw new Exception("URL {$url} doesn't exist");
        }

        return $response->content;
    }
876457
protected function fetchEndpointForUrl($url)
    {
        $client = new Client($url);

        $body = $client->send();

        $regexp = str_replace(
            '@formats@',
            implode('|', $this->supportedFormats),
            self::LINK_REGEXP
        );

        if (!preg_match_all($regexp, $body, $matches, PREG_SET_ORDER)) {
            throw new \InvalidArgumentException('No valid oEmbed links found on page.');
        }

        foreach ($matches as $match) {
            if ($match['Format'] === $this->preferredFormat) {
                return $this->extractEndpointFromAttributes($match['Attributes']);
            }
        }

        return $this->extractEndpointFromAttributes($match['Attributes']);
    }
34335
public function addUrl(Url $url)
    {
        if ($this->isFull()) {
            throw new \RuntimeException('The urlset limit has been exceeded');
        }

        $urlXml = $url->toXml();
        $this->appendXML($urlXml);

        //add unknown custom namespaces
        $this->customNamespaces = array_merge($this->customNamespaces, $url->getCustomNamespaces());

        //---------------------
        //Check limits
        if ($this->countItems++ >= self::LIMIT_ITEMS) {
            $this->limitItemsReached = true;
        }

        $urlLength = strlen($urlXml);
        $this->countBytes += $urlLength;

        if ($this->countBytes + $urlLength + strlen($this->getStructureXml()) > self::LIMIT_BYTES) {
            //we suppose the next url is almost the same length and cannot be added
            //plus we keep 500kB (@see self::LIMIT_BYTES)
            //... beware of numerous images set in url
            $this->limitBytesReached = true;
        }
        //---------------------
    }
1039702
public function initURL($url)
    {
        $contents = file_get_contents($url);

        $lines = explode("\n", $contents);

        return $this->initLines($lines);
    }
279958
def expand(self, url):
        """"""
        url = self.clean_url(url)
        response = self._get(url)
        if response.ok:
            return response.url
        raise ExpandingErrorException