public function absolute($baseUrl)
    {
        $url = $this->url;

        $pos = strpos($url, '://');
        if ($pos === false || $pos > 10) {
            $parsed = parse_url($baseUrl) + array(
                    'path' => '',
                );
            if (!isset($parsed['scheme'], $parsed['host']))
                throw new \Exception('Invalid base url "' . $baseUrl . '": scheme not found.');

            if (empty($url))
                return $baseUrl;

            if (strncmp($url, '//', 2) == 0) {
                return $parsed['scheme'] . ':' . $url;
            }

            $fullHost = $parsed['scheme'] . '://' . $parsed['host'];

            if (substr($url, 0, 1) == '?') {
                return $fullHost . $parsed['path'] . $url;
            }

            if (substr($url, 0, 1) == '/') {
                return $fullHost . $url;
            }

            $pathParts = explode('/', $parsed['path']);
            array_pop($pathParts);

            while (substr($url, 0, 3) == '../') {
                array_pop($pathParts);
                $url = substr($url, 3);
            }

            return $fullHost . implode('/', $pathParts) . '/' . $url;
        }

        return $url;
    }