private static function parseUrl($url, $component)
{
if (!isset(self::$cache[$url]['url'])) {
// Strip protocol
$scheme = parse_url($url, PHP_URL_SCHEME);
$url = str_replace($scheme . '://', '', $url);
$url = str_replace($scheme . ':', '', $url);
// Punycode encode domain
$host = parse_url('http://' . $url, PHP_URL_HOST);
$punycode = new Punycode();
$url = str_replace($host, $punycode->encode($host), $url);
// Add back normalized protocol
$url = 'http://' . $url;
// Remove all illegal characters from a url
$url = filter_var($url, FILTER_SANITIZE_URL);
// Sanity check
if (($check = filter_var($url, FILTER_VALIDATE_URL)) === false) {
$url = false;
}
self::$cache[$url]['url'] = $url;
}
return parse_url(strtolower(self::$cache[$url]['url']), $component);
}