Graby\Graby::makeAbsolute PHP Method

makeAbsolute() private method

Make an absolute url from an element.
private makeAbsolute ( string $base, DOMNode $elem )
$base string The base url
$elem DOMNode Element on which we'll retrieve the attribute
    private function makeAbsolute($base, \DOMNode $elem)
    {
        $base = new \SimplePie_IRI($base);
        // remove '//' in URL path (used to prevent URLs from resolving properly)
        if (isset($base->ipath)) {
            $base->ipath = str_replace('//', '/', $base->ipath);
        }
        foreach (array('a' => 'href', 'img' => 'src', 'iframe' => 'src') as $tag => $attr) {
            $elems = $elem->getElementsByTagName($tag);
            for ($i = $elems->length - 1; $i >= 0; --$i) {
                $e = $elems->item($i);
                $this->makeAbsoluteAttr($base, $e, $attr);
            }
            if (strtolower($elem->nodeName) == $tag) {
                $this->makeAbsoluteAttr($base, $elem, $attr);
            }
        }
    }