According to the `[HTML spec](http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-base-element), the base url need to be resolved relatively to the document uri. It does not need to be an absolute uri.

Your code is only supporting 1 case of the resolution instead of all. the proper way would be to reuse the existing resolution here:

```php
// change the extraction to get the first ``base`` element instead of only its ``href`` attribute
$baseNode = // ...;

$link = new Link($baseNode, $this->uri);
$this->uri = $link->getUri();
```