Tell whether both URI refers to the same document.

@param Psr7UriInterface|UriInterface $uri
@param Psr7UriInterface|UriInterface $base_uri
551117
public static function isSameDocument($uri, $base_uri): bool
    {
        $uri = self::normalize($uri);
        $base_uri = self::normalize($base_uri);

        return (string) $uri->withFragment($uri instanceof Psr7UriInterface ? '' : null)
            === (string) $base_uri->withFragment($base_uri instanceof Psr7UriInterface ? '' : null);
    }
265829
public function getRelated(Uri $baseUri)
    {
        $path = $baseUri->getPath();
        if (substr($this->getPath(), 0, strlen($path)) == $path) {
            $class = get_called_class();
            $uri = new $class('');
            $uri->fragment = $this->fragment;
            $uri->path = substr($this->getPath(), strlen($path));
            $uri->query = $this->query;
            return $uri;
        }
        return $this;
    }
336913
public function match(string $uri): bool
    {
        if ($this->uri == $uri) {
            return true;
        }
        $pattern = '/^' . $this->regex . '$/';
        return !is_null($this->regex) && preg_match($pattern, $uri);
    }
714568
protected static boolean isAPIUri(Uri uri) {
        if (uri == null) {
            return false;
        }

        return getBaseUri().getHost().equals(uri.getHost());
    }
823926
private function createUri($uri)
    {
        if ($this->hasBaseUri() && (stripos($uri, $baseUri = (string) $this->getBaseUri()) === false)) {
            return $baseUri.$uri;
        }

        return $uri;
    }
1247015
public static function validateURI($uri) {
        if(!empty(trim($uri))){
            return filter_var(trim($uri), FILTER_VALIDATE_URL);
        }
        return false;
    }
292621
protected function isRelativeUri($uri)
    {
        if ($uri && !parse_url($uri, PHP_URL_SCHEME)) {
            if (!in_array($uri[0], [ '/', '#', '?' ])) {
                return true;
            }
        }

        return false;
    }
1309412
public function resolve(UriInterface $uri, UriInterface $baseUri)
    {
        $baseUriReflector = new ReflectionObject($baseUri);
        if (!$baseUriReflector->hasMethod('resolve')) {
            $baseUri = new Uri($baseUri->toString());
            if ($uri instanceof Uri) {
                $uri = clone $uri;
            } else {
                $uri = new Uri($uri->toString());
            }
        } elseif (!$uri instanceof $baseUri) {
            $uri = $baseUriReflector->newInstance($uri->toString());
        } else {
            $uri = clone $uri;
        }

        return $uri->resolve($baseUri);
    }
1242113
function relativeURI(uri, base) {
    
    // reduce base and uri strings to just their difference string
    var baseParts = base.split('/');
    baseParts.pop();
    base = baseParts.join('/') + '/';
    i = 0;
    while (base.substr(i, 1) == uri.substr(i, 1))
      i++;
    while (base.substr(i, 1) != '/')
      i--;
    base = base.substr(i + 1);
    uri = uri.substr(i + 1);

    // each base folder difference is thus a backtrack
    baseParts = base.split('/');
    var uriParts = uri.split('/');
    out = '';
    while (baseParts.shift())
      out += '../';
    
    // finally add uri parts
    while (curPart = uriParts.shift())
      out += curPart + '/';
    
    return out.substr(0, out.length - 1);
  }
1297940
public function &findPageByUri($uri)
    {
        foreach ($this->getRootSection()->getSections() as $section) {
            if ($page = $section->findPageByUri($uri)) {
                return $page;
            }
        }

        return;
    }
1294863
private function setUri($uri)
    {
        $this->uri = $uri;

        preg_match_all('/({[^}]+})/', $this->uri, $matches);
        $this->params = $matches[0];

        return $this;
    }
466565
protected function makeUriRelativeTo($uri, $root)
    {
        if (!$root) {
            return $uri;
        }

        if (is_array($uri)) {
            $uris = [];
            foreach ($uri as $u) {
                $uris[] = $this->makeUriRelativeTo($u, $root);
            }
            return $uris;
        }

        if (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri)) {
            return $uri;
        }
        return rtrim($root, '/') . "/$uri";
    }
666785
public function get(string $uri): Description
    {
        if (!$uri) {
            throw new \InvalidArgumentException("No document URI provided");
        }
        if ($this->basePath) {
            $uri = "$this->basePath/$uri";
        }
        if (!isset($this->specifications[$uri])) {
            $this->specifications[$uri] = $this->load($uri);
        }

        return $this->specifications[$uri];
    }
452720
public function isIgnoredExtension($uri)
    {
        foreach ($this->ignoredExtensions as $ignoredExtension) {
            if (strpos($uri, $ignoredExtension) !== false) {
                return true;
            }
        }

        return false;
    }
376770
public function withBaseUri(string $uri): self
    {
        return tap($this, function ($request) use ($uri) {
            return $this->options = array_merge_recursive($this->options, [
                'base_uri' => $uri,
            ]);
        });
    }
693001
private static function mergeUrl($uri, $baseUrl)
    {
        $href = parse_url($uri);
        $base = parse_url($baseUrl);
        $full = $href + $base + parse_url('http://localhost/');
        return $full['scheme'].'://'.$full['host'].$full['path'];
    }
1145334
public static function create($uri, $base_uri = null): self
    {
        return new self(Uri::create($uri, $base_uri));
    }