Graby\Extractor\HttpClient::getMetaRefreshURL PHP Method

getMetaRefreshURL() private method

Try to find the refresh url from the meta.
private getMetaRefreshURL ( string $url, string $html ) : false | string
$url string Absolute url
$html string First characters of the response (hopefully it'll be enough to find some meta)
return false | string
    private function getMetaRefreshURL($url, $html)
    {
        if ($html == '') {
            return false;
        }
        // <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.bernama.com/bernama/v6/newsindex.php?id=943513">
        if (!preg_match('!<meta http-equiv=["\']?refresh["\']? content=["\']?[0-9];\\s*url=["\']?([^"\'>]+)["\']?!i', $html, $match)) {
            return false;
        }
        $redirectUrl = str_replace('&amp;', '&', trim($match[1]));
        if (preg_match('!^https?://!i', $redirectUrl)) {
            // already absolute
            $this->logger->log('debug', 'Meta refresh redirect found (http-equiv="refresh"), new URL: ' . $redirectUrl);
            return $redirectUrl;
        }
        // absolutize redirect URL
        $base = new \SimplePie_IRI($url);
        // remove '//' in URL path (causes URLs not to resolve properly)
        if (isset($base->ipath)) {
            $base->ipath = str_replace('//', '/', $base->ipath);
        }
        if ($absolute = \SimplePie_IRI::absolutize($base, $redirectUrl)) {
            $this->logger->log('debug', 'Meta refresh redirect found (http-equiv="refresh"), new URL: ' . $absolute);
            return $absolute->get_iri();
        }
        return false;
    }