Converts the relative URI into a new URI that is resolved against the base URI.

@param string|UriInterface $base Base URI
@param string|UriInterface $rel Relative URI

@return UriInterface

@see UriResolver::resolve
170577
public static function resolve($base, $rel): ?UriInterface
    {
        if ($base && $rel) {
            if (!($base instanceof UriInterface)) {
                $base = new self($base);
            }
            if (!($rel instanceof UriInterface)) {
                $rel = new self($rel);
            }
            return UriResolver::resolve($base, $rel);
        } elseif ($rel) {
            return $rel instanceof UriInterface ? $rel : new self($rel);
        } elseif ($base) {
            return $base instanceof UriInterface ? $base : new self($base);
        } else {
            return null;
        }
    }
890606
public function setBaseUrl($base_url) {
        $this->base_url = '/' . trim($base_url, '/') . '/';
        $this->base_url = str_replace('//', '/', $this->base_url);

        return $this;
    }
1201672
public static function getRelativePath(UriInterface $baseUri, UriInterface $uri): string
    {
        // FIXME: We should probably do a strpos === 0 instead to make sure the baseUri actually matches the start of the Uri.
        $baseUriLength = strlen($baseUri->getPath());
        if ($baseUriLength >= strlen($uri->getPath())) {
            return '';
        }

        return substr($uri->getPath(), $baseUriLength);
    }
350138
protected static function resolveRelativeUrlAfterEarlyChecks(string $base, string $rel): string
    {
        /* fix url file for Windows */
        $base = preg_replace('#^file:\/\/([^/])#', 'file:///\1', $base);

        /**
         * @var mixed[]
         *
         * parse base URL and convert to local variables:
         * $scheme, $host, $path
         */
        $parts = parse_url($base);

        return static::resolveRelativeUrlToAbsoluteUrl(
            $rel,
            (
                $rel[0] === '/'
                    ? ''  // destroy path if relative url points to root
                    : ( // remove non-directory element from path
                        isset($parts['path'])
                            ? preg_replace(
                                '#/[^/]*$#',
                                '',
                                (string) $parts['path']
                            )
                            : ''
                    )
            ),
            $parts
        );
    }
870660
private function makeAbsoluteStr($base, $url)
    {
        if (!$url) {
            return false;
        }

        if (preg_match('!^https?://!i', $url)) {
            // already absolute
            return $url;
        }

        $base = new \SimplePie_IRI($base);

        // remove '//' in URL path (causes URLs not to resolve properly)
        if (isset($base->ipath)) {
            $base->ipath = preg_replace('!//+!', '/', $base->ipath);
        }

        if ($absolute = \SimplePie_IRI::absolutize($base, $url)) {
            return $absolute->get_uri();
        }

        return false;
    }
1211565
public function gotoURL($url, $base = true)
    {
        if ($base) {
            $url = $this->app->baseURL . $url;
        }

        $this->js('location.href="'.$url.'";');
    }
696718
public function setBaseUri($uri) : self
    {
        $this->baseUri = $uri instanceof Uri ? $uri : new Uri($uri);

        return $this;
    }
400049
public static function absolutize($base, $relative)
	{
		if (!($relative instanceof SimplePie_IRI))
		{
			$relative = new SimplePie_IRI($relative);
		}
		if (!$relative->is_valid())
		{
			return false;
		}
		elseif ($relative->scheme !== null)
		{
			return clone $relative;
		}
		else
		{
			if (!($base instanceof SimplePie_IRI))
			{
				$base = new SimplePie_IRI($base);
			}
			if ($base->scheme !== null && $base->is_valid())
			{
				if ($relative->get_iri() !== '')
				{
					if ($relative->iuserinfo !== null || $relative->ihost !== null || $relative->port !== null)
					{
						$target = clone $relative;
						$target->scheme = $base->scheme;
					}
					else
					{
						$target = new SimplePie_IRI;
						$target->scheme = $base->scheme;
						$target->iuserinfo = $base->iuserinfo;
						$target->ihost = $base->ihost;
						$target->port = $base->port;
						if ($relative->ipath !== '')
						{
							if ($relative->ipath[0] === '/')
							{
								$target->ipath = $relative->ipath;
							}
							elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '')
							{
								$target->ipath = '/' . $relative->ipath;
							}
							elseif (($last_segment = strrpos($base->ipath, '/')) !== false)
							{
								$target->ipath = substr($base->ipath, 0, $last_segment + 1) . $relative->ipath;
							}
							else
							{
								$target->ipath = $relative->ipath;
							}
							$target->ipath = $target->remove_dot_segments($target->ipath);
							$target->iquery = $relative->iquery;
						}
						else
						{
							$target->ipath = $base->ipath;
							if ($relative->iquery !== null)
							{
								$target->iquery = $relative->iquery;
							}
							elseif ($base->iquery !== null)
							{
								$target->iquery = $base->iquery;
							}
						}
						$target->ifragment = $relative->ifragment;
					}
				}
				else
				{
					$target = clone $base;
					$target->ifragment = null;
				}
				$target->scheme_normalization();
				return $target;
			}

			return false;
		}
	}
164804
public static String relativize(String base, String uri)
	{
		URI child = URI.create( raw( uri ) );
		URI parent = URI.create( raw( base ) );
		return parent.relativize( child ).getPath();
	}
1284526
public function getResource($rel)
    {
        $resources = $this->getResources();

        if (isset($resources[$rel])) {
            return $resources[$rel];
        }

        return null;
    }
1328911
public function resolve($url)
    {
        $baseUrl = Utils::sanitizeUri($this->getBasePath());
        $baseDir = pathinfo($baseUrl, PATHINFO_DIRNAME);

        if (empty($baseDir)) {
            $msg = "The base directory of the document ('${baseDir}') could not be resolved.";
            throw new ResolutionException($msg);
        }

        $href = $baseDir . '/' . ltrim($url, '/');

        return $href;
    }
81240
public function getLink($rel)
    {
        foreach ($this->getLinks() as $link) {
            if (isset($link['rel']) && $link['rel'] == $rel) {
                return $link;
            }
        }

        return null;
    }
1007029
public function resolve($uri, $baseUri = null)
    {
        $components = $this->parse($uri);
        $path = $components['path'];

        if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
            return $uri;
        }

        $baseComponents = $this->parse($baseUri);
        $basePath = $baseComponents['path'];

        $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);

        return $this->generate($baseComponents);
    }
1264577
public function base($baseUri)
    {
        return new Base($this->pdo, $baseUri, $this->curlOptions, $this->byteLimit);
    }
112666
protected function createBaseRequest($relativeUrl)
	{
		$baseUrl = $this->getBaseUrl(false);
		$request = new \Zend\Http\Request();
		$request->setUri($baseUrl.$relativeUrl);
		$request->setMethod(\Zend\Http\Request::METHOD_POST);
		$request->getHeaders()->addHeaders(array(
			'Content-Type'=>'application/x-www-form-urlencoded; charset=UTF-8',
			'Accept-Encoding'=>'identity')); // plain text

		$this->addDefaultParameters($request);

		return $request;
	}
216776
public function get(string $rel): HalLink
    {
        if (!$this->has($rel)) {
            throw new InvalidArgumentException(sprintf('The link "%s" was not found', $rel));
        }

        return $this->links[$rel];
    }
1199321
public function withBasePath($basePath)
    {
        if (!is_string($basePath)) {
            throw new InvalidArgumentException('Uri path must be a string');
        }
        if (!empty($basePath)) {
            $basePath = '/' . trim($basePath, '/'); // <-- Trim on both sides
        }
        $clone = clone $this;

        if ($basePath !== '/') {
            $clone->basePath = $this->filterPath($basePath);
        }

        return $clone;
    }