Whether the URI is a relative-path reference.

A relative reference that does not begin with a slash character is termed a relative-path reference.

@param UriInterface $uri

@return bool

@see https://tools.ietf.org/html/rfc3986#section-4.2
486482
public static function isRelativePathReference(UriInterface $uri)
    {
        $path = $uri->getPath();

        return '' === $uri->getScheme()
            && '' === $uri->getAuthority()
            && (!isset($path[0]) || '/' !== $path[0]);
    }
256001
public function getPath(UriInterface $uri)
    {
        $path  = trim($uri->getPath(), '/');
        $parts = explode('/', $path);

        if ($parts[0] === 'v'.Client::API_VERSION) {
            unset($parts[0]);
        }

        return '/'.implode('/', $parts);
    }
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);
    }
243871
private function getPathWithQuery(UriInterface $uri): string
    {
        $uriString = $uri->getPath();

        if (!empty($uri->getQuery())) {
            $uriString .= self::DELIMITER_URL_QUERY . $uri->getQuery();
        }

        return $uriString;
    }
867254
protected static function mergePaths(Uri $baseUri, string $relative): string
    {
        $basePath = $baseUri->path();

        if ($baseUri->authority() !== null && $basePath === '') {
            return sprintf('/%s', $relative);
        }

        $last = strrpos($basePath, '/');

        if ($last !== false) {
            return sprintf('%s/%s', substr($basePath, 0, $last), $relative);
        }

        return $relative;
    }
1087473
public function load(UriInterface $uri)
    {
        if (!$uri instanceof FileUriInterface) {
            throw new InvalidUriTypeException(
                $uri,
                'Eloquent\Schemer\Uri\FileUriInterface'
            );
        }

        $path = $this->pathFromUri($uri);

        try {
            $data = $this->isolator->file_get_contents($path);
        } catch (ErrorException $e) {
            throw new LoadException($uri, $e);
        }

        return new Content($data, $this->extensionMap()->getByPath($path));
    }
500425
public static function isAbsolutePathReference(UriInterface $uri)
    {
        $uriPath = $uri->getPath();
        return $uri->getScheme() === ''
            && $uri->getAuthority() === ''
            && isset($uriPath[0])
            && $uriPath[0] === '/';
    }
956241
private function replaceHostHeader(UriInterface $uri)
    {
        $host = $uri->getHost();

        if (!empty($host)) {

            $port = $uri->getPort();
            if (!empty($port)) {
                $host .= ':' . $port;
            }

            //~ Ensure Host is the first header. See: http://tools.ietf.org/html/rfc7230#section-5.4
            $this->headersOriginal = ['Host' => [$host]] + $this->headersOriginal;
            $this->headers         = ['host' => [$host]] + $this->headers;
        }
    }
517274
protected function resolution(UriInterface $referenceUri)
    {
        $key = $referenceUri->toString();
        if (array_key_exists($key, $this->resolutions)) {
            return $this->resolutions[$key];
        }

        return null;
    }
1142909
protected function pathFromUri(FileUriInterface $uri)
    {
        $path = $uri->getPath();
        if (null === $path) {
            $path = '';
        }

        return $path;
    }
540620
public function pointerByUri(UriInterface $uri)
    {
        $uriPointerMap = $this->createUriPointerMap($uri);

        foreach ($this->map() as $tuple) {
            list($mappingPointer, $mappingUri) = $tuple;
            $mappingUriString = $mappingUri->toString();

            foreach ($uriPointerMap as $tuple) {
                list($uriString, $atoms) = $tuple;

                if ($uriString === $mappingUriString) {
                    return $mappingPointer->joinAtomSequence($atoms);
                }
            }
        }

        return null;
    }
583719
private static function normalizePath($uri, $path = null)
    {
        if ($path instanceof PathInterface) {
            $path = $path->getContent();
        }

        $path = $path ?? $uri->getPath();
        $path = (string) $path;
        if (null !== $uri->getAuthority()
            && '' !== $uri->getAuthority()
            && '' !== $path
            && '/' != ($path[0] ?? '')
        ) {
            return $uri->withPath('/'.$path);
        }

        return $uri->withPath($path);
    }
1106816
public static function base($uri = '', $relativeTo = '')
    {
        $app = App::getInstance();

        $scheme = parse_url($uri, PHP_URL_SCHEME);
        if (isset($scheme)) {
            return $uri;
        }

        // We use server script name instead from slim env script name
        // because slim env script name truncate the index.php file from the
        // result
        $dir = $_SERVER['SCRIPT_NAME'];
        if (substr($dir, -4) === '.php') {
            $dir = dirname($dir);
        }

        if ($dir === '/') {
            $dir = '';
        }

        if ($relativeTo === false) {
            $relativeTo = $dir;
        } elseif (!$relativeTo) {
            $relativeTo = $app->environment['slim.url_scheme'].'://'.$app->environment['HTTP_HOST'].$dir;
        }

        return $relativeTo.'/'.trim($uri, '/');
    }
944360
public function setUri( $uri )
    {
        $uri = (string) $uri;

        if ( empty( $uri ) )
        {
            $uri = '#';
        }
        else if ( ! preg_match( '(^(' . static::VALID_SCHEMES . '))', $uri ) )
        {
            if ( preg_match( '(^[a-z0-9-]+(\.[a-z0-9-]+)+(/.*)?$)', $uri ) )
            {
                $uri = static::DEFAULT_SCHEME . $uri;
            }
            else
            {
                $uri = '/' . ltrim( $uri, '/' );
            }
        }

        $this->uri = $uri;
        return $this;
    }
1183271
protected function getUriInterface($uri)
    {
        if ($uri instanceof UriInterface) {
            return UriInterface::class;
        }

        if ($uri instanceof Uri) {
            return Uri::class;
        }

        throw Exception::fromInvalidUri($uri);
    }
917673
protected function isOpenSymphonyUrl(UriInterface $uri)
    {
        $host = $uri->getHost();
        $host = strtolower($host);
        $host = trim($host);

        $flag = self::VALID_URI === $host;

        return $flag;
    }
324601
public static function isRelativePathReference(UriInterface $uri)
    {
        $uriPath = $uri->getPath();
        return $uri->getScheme() === ''
            && $uri->getAuthority() === ''
            && (!isset($uriPath[0]) || $uriPath[0] !== '/');
    }