Unirest\Request::encodeUrl PHP Method

encodeUrl() private static method

Ensure that a URL is encoded and safe to use with cURL
private static encodeUrl ( string $url ) : string
$url string URL to encode
return string
    private static function encodeUrl($url)
    {
        $url_parsed = parse_url($url);
        $scheme = $url_parsed['scheme'] . '://';
        $host = $url_parsed['host'];
        $port = isset($url_parsed['port']) ? $url_parsed['port'] : null;
        $path = isset($url_parsed['path']) ? $url_parsed['path'] : null;
        $query = isset($url_parsed['query']) ? $url_parsed['query'] : null;
        if ($query !== null) {
            $query = '?' . http_build_query(self::getArrayFromQuerystring($query));
        }
        if ($port && $port[0] !== ':') {
            $port = ':' . $port;
        }
        $result = $scheme . $host . $port . $path . $query;
        return $result;
    }