@param Url $url

@return string
481562
protected function urlToDsn(Url $url)
    {

        $driver = $url->scheme;
        $db = $url->path ? $url->path : '';
        $port = $url->port;
        $host = $url->host;

        if ($driver == 'sqlite') {
            return $host == 'memory' ? 'sqlite::memory:' : "sqlite:$db";
        }

        $parts = [];

        if ($db) {
            $parts[] = "dbname=" . trim($db, '/');
        }

        if ($host) {
            $parts[] = "host=$host";
        }

        if ($port) {
            $parts[] = "port=$port";
        }

        return "$driver:" . implode(';', $parts);

    }
725985
private function getRequest($url) {
    $part = parse_url($url);

    if(isset($part['query'])) {
      parse_str($part['query'], $query);
      if(isset($query[$this->getParam])) {
        unset($query[$this->getParam]);
      }
      if(sizeof($query) > 0) {
        $request = $part['path'].http_build_query($query);
      } else {
        $request = $part['path'];
      }
    } else {
      $request = $part['path'];
    }

    return $request;
  }
1066746
public static function urlToPath($url)
    {
        $path = str_replace('http://', '', $url);
        $path = str_replace('https://', '', $path);
        $path = str_replace($_SERVER['HTTP_HOST'], '', $path);

        if (substr($path, 0, 1) == '/') {
            $path = substr($path, 1);
        }

        return $_SERVER['DOCUMENT_ROOT'] . '/' . $path;
    }
1181737
protected function parseStringUrl(?string $url) : string
    {
        $parts = parse_url($url);

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

        return $this->create(
            $parts['scheme'] ?? null,
            $parts['host'] ?? null,
            $parts['path'] ?? null,
            $query ?? null,
            $parts['fragment'] ?? null,
            (Str::endsWith($url, '/')
                && (isset($parts['path'])
                    && ($parts['path'] !== '/' || !empty($parts['path']))) )
        );
    }
1259967
private function getRequestPath($url) {
		$urlParts = parse_url($url);
		$path = $urlParts['path'];
		if (isset($urlParts['query'])) {
			$path .= '?' . $urlParts['query'];
		}
		if (isset($urlParts['fragment'])) {
			$path .= '#' . $urlParts['fragment'];
		}
		return $path;
	}
1052478
public function getAbsolute($url)
    {
        $url = trim($url);

        if (empty($url)) {
            return '';
        }

        if (preg_match('|^\w+:[^/]|', $url)) {
            return $url;
        }

        if (preg_match('|^\w+://|', $url)) {
            return self::validUrlOrEmpty($url);
        }

        if (strpos($url, '://') === 0) {
            return self::validUrlOrEmpty($this->getScheme().$url);
        }

        if (strpos($url, '//') === 0) {
            return self::validUrlOrEmpty($this->getScheme().":$url");
        }

        if ($url[0] === '/') {
            return self::validUrlOrEmpty($this->getScheme().'://'.$this->getHost().$url);
        }

        return self::validUrlOrEmpty($this->getScheme().'://'.$this->getHost().$this->getDirectories().$url);
    }
298226
public function checkLink($url)
    {
        $url = trim($url);
        if (substr($url, 0, 7 ) == "http://") return $url;

        if (substr($url, 0, 8 ) == "https://") return $url;

        return "http://".$url;
    }
45460
public function canonicalUrl($url)
    {
        if (strlen($url)) {
            if ($url[0] == '/') {
                // If the URL begins with a "/", the following is the
                // canonical URL
                return substr($url, 1);
            } else {
                // Else, the canonical name is under the current dir
                if ($this->getDirName()) {
                    return $this->canonicalize($this->getDirName() . '/' .$url);
                } else {
                    return $this->canonicalize($url);
                }
            }
        }

        return null;
    }
218361
public static function retrieveUri($url)
    {
        $uri = new Psr7Uri($url);
        return (string)(new Psr7Uri())
            ->withPath($uri->getPath())
            ->withQuery($uri->getQuery())
            ->withFragment($uri->getFragment());
    }
279701
private function getPath($url)
    {
        $url = trim($url);
        $parsed = $this->parseURL($url);
        if ($parsed !== false) {
            $this->url = $url;
            return $parsed['custom'];
        }
        return $url;
    }
556233
protected static function encode_url($url)
    {
        $reserved = array(
            ':' => '!%3A!ui',
            '/' => '!%2F!ui',
            '?' => '!%3F!ui',
            '#' => '!%23!ui',
            '[' => '!%5B!ui',
            ']' => '!%5D!ui',
            '@' => '!%40!ui',
            '!' => '!%21!ui',
            '$' => '!%24!ui',
            '&' => '!%26!ui',
            "'" => '!%27!ui',
            '(' => '!%28!ui',
            ')' => '!%29!ui',
            '*' => '!%2A!ui',
            '+' => '!%2B!ui',
            ',' => '!%2C!ui',
            ';' => '!%3B!ui',
            '=' => '!%3D!ui',
            '%' => '!%25!ui'
        );
        $url = preg_replace(array_values($reserved), array_keys($reserved), rawurlencode($url));
        return $url;
    }
1193931
private function buildUrl($url)
    {
        $url = $this->protocol . '://' . $url . '/';

        if ($this->date) {
            $url .= $this->date;
        } else {
            $url .= 'latest';
        }

        $url .= '?base=' . $this->base;

        if ($this->key) {
            $url .= '&access_key=' . $this->key;
        }

        if ($symbols = $this->symbols) {
            $url .= '&symbols=' . implode(',', $symbols);
        }

        return $url;
    }
657345
public function get(string $url): string
    {
        $ch = curl_init($url);

        if ( ! ini_get('open_basedir')) {
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        }

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_VERBOSE, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36');
        curl_setopt($ch, CURLOPT_URL, $url);

        $content = curl_exec($ch);
        if ($content === false) {
            // there was a problem
            $error = curl_error($ch);
            throw new CurlException('Error retrieving "'.$url.'" ('.$error.')');
        }

        return $content;
    }
540478
protected function getUrlContents(string $url): string
    {
        $request = $this->getRequest($url);

        return $this->getParsedResponse($request);
    }
1089956
protected function prepareUrl($url)
    {
        if (Str::startsWith($url, '/')) {
            $url = substr($url, 1);
        }

        if (! Str::startsWith($url, 'http')) {
            $url = sprintf("%s/%s", $this->baseUrl(), $url);
        }

        return trim($url, '/');
    }
679241
private function cleanUrl($url)
    {
        if (strlen($url) > 1 && strrpos($url, '/') === strlen($url) - 1) {
            $url = substr($url, 0, -1);
        }
        if (strrpos($url, '.php') === strlen($url) - 4) {
            $url = substr($url, 0, -4);
        }
        return $url;
    }
354227
public function normalizeUrl($url)
    {
        $url = trim($url, '/') .'/';

        // if the page is the index page then hide it from the menu
        if (strpos(strtolower($url), '/index.md/')) {
            $url = substr($url, 0, strpos($url, "index.md/"));
        }

        return $url;
    }