Whether the URI is a absolute-path reference.

A relative reference that begins with a single slash character is termed an absolute-path reference.

@param UriInterface $uri

@return bool
@link https://tools.ietf.org/html/rfc3986#section-4.2
500425
public static function isAbsolutePathReference(UriInterface $uri)
    {
        $uriPath = $uri->getPath();
        return $uri->getScheme() === ''
            && $uri->getAuthority() === ''
            && isset($uriPath[0])
            && $uriPath[0] === '/';
    }
857499
public static boolean isAbsoluteURI( String uri )
    {
         //
         // This method needs to be fast, so it can't use java.net.URI.
         //
         if ( uri.length() == 0 || uri.charAt( 0 ) == '/' ) return false;
        
         for ( int i = 0, len = uri.length(); i < len; ++i )
         {
             char c = uri.charAt( i );
            
             if ( c == ':' )
             {
                 return true;
             }
             else if ( c == '/' )
             {
                 return false;
             }
         }
        
         return false;
     }
1124028
protected function parseUri($uri)
    {
        if ($uri && stripos($uri, 'unix://') === 0) {
            // parse_url() doesn't like "unix:///foo", but parses "unix:/foo" fine.
            $uri = str_ireplace('unix://', 'unix:', $uri);
        } elseif ($uri && $uri[0] !== '/' && !preg_match('#^\w+://?.+#', $uri)) {
            // If no scheme given and path exists and isn't absolute, assume tcp scheme is wanted.
            // This allows both "127.0.0.1" and "/foo.sock" to work without specifying scheme.
            // If non absolute path is wanted, specify the scheme: "unix://foo.sock"
            $uri = 'tcp://' . $uri;
        }

        $parsed = new Uri($uri);

        return $parsed;
    }
755662
public static function isUri($value): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        // http://tools.ietf.org/html/rfc3986
        //
        // URI         = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
        // hier-part   = "//" authority path-abempty
        //             / path-absolute
        //             / path-rootless
        //             / path-empty
        $pattern = sprintf(
            '/\A%s%s%s%s%s\z/',
            '(?:([^:\/?#]+)(:))?',
            '(?:(\/\/)([^\/?#]*))?',
            '([^?#]*)',
            '(?:(\?)([^#]*))?',
            '(?:(#)(.*))?'
        );

        preg_match($pattern, (string) $value, $matches);
        $uri = self::uriComponentsFromMatches($matches);

        return self::isValidUri($uri);
    }
751919
public function isMatch(string $uri): bool {
        list($path) = explode('?', $uri, 2);
        if ($path === '') {
            $path = trim($this->conf['default'], '/');
        }
        /** @noinspection ReturnFalseInspection */
        $lastDotPos = strrpos($path, '.');
        $suffix = '';
        if (false !== $lastDotPos) {
            $suffix = substr($path, $lastDotPos + 1);
            $path = substr($path, 0, $lastDotPos);
        }
        $parts = explode('/', $path);
        $this->args = [];
        while (count($parts)) {
            $p = $parts;
            $lastPart =& $p[count($p) - 1];
            $lastPart = Toolkit::toCamelCase($lastPart, true);
            $className = 'action\\' . implode('\\', $p);
            $classNameAction = $className . 'Action';
            $this->action = null;
            if (class_exists($classNameAction)) {
                $this->action = new $classNameAction();
            } else if (class_exists($className)) {
                $this->action = new $className();
            }

            if ($this->action instanceof Action) {
                $this->action->suffix = $suffix;
                return true;
            } elseif ($this->action !== null) {
                X::logger()->warn('Class ' . get_class($this->action) .
                    " is in the action namespace but not an instance of x2ts\\route\\Action.\n" .
                    "Please check the inheriting chain.");
            }
            array_unshift($this->args, array_pop($parts));
        }

        return false;
    }
914191
public static function create($uri, $base_uri = null): UriInterface
    {
        if (!$uri instanceof UriInterface) {
            $uri = self::createFromString($uri);
        }

        if (null === $base_uri) {
            if (null === $uri->getScheme()) {
                throw new SyntaxError(sprintf('the URI `%s` must be absolute', (string) $uri));
            }

            if (null === $uri->getAuthority()) {
                return $uri;
            }

            return UriResolver::resolve($uri, $uri->withFragment(null)->withQuery(null)->withPath(''));
        }

        if (!$base_uri instanceof UriInterface) {
            $base_uri = self::createFromString($base_uri);
        }

        if (null === $base_uri->getScheme()) {
            throw new SyntaxError(sprintf('the base URI `%s` must be absolute', (string) $base_uri));
        }

        return UriResolver::resolve($uri, $base_uri);
    }
539134
public function withUrlPath(UrlPathInterface $urlPath): UrlPathInterface
    {
        if (!$this->myCombine($urlPath, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error)) {
            throw new UrlPathLogicException('Url path "' . $this->__toString() . '" can not be combined with url path "' . $urlPath->__toString() . '": ' . $error);
        }

        return new self($isAbsolute, $aboveBaseLevel, $directoryParts, $filename);
    }
1242216
public function isUriPrefixExcluded($uri)
    {
        foreach ($this->excludedUriPrefixes as $excludedPrefix) {
            $excludedPrefix = '/' . trim($excludedPrefix, '/');
            if (mb_stripos($uri, $excludedPrefix) === 0) {
                return true;
            }
        }

        return false;
    }
1070080
public static function getPassword(UriInterface $uri): string
    {
        $userInfo = explode(':', $uri->getUserInfo());

        return (isset($userInfo[1]) ? $userInfo[1] : '');
    }
1022342
public function cookieDomain(UriInterface $uri): ?string
    {
        $host = $uri->getHost();
        if (empty($host)) {
            return null;
        }

        $pattern = $this->config['cookies']['domain'];
        if (preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) {
            // remove port
            $host = $matches[1];
        }

        if (filter_var($host, FILTER_VALIDATE_IP) || $host == 'localhost') {
            //We can't use sub-domains when website required by IP
            $pattern = ltrim($pattern, '.');
        }

        if (strpos($pattern, '%s') === false) {
            //Forced domain
            return $pattern;
        }

        return sprintf($pattern, $host);
    }
986525
public function checkRoute($uri)
    {
        foreach($this->strings as $expression)
        {
            // check if it matches the pattern
            $this->regex->setPattern($expression);
            if($this->regex->getMatches($uri))
            {
                $this->matchedUriParts = explode('/',$uri);
                return true;
            }
        }
        return false;
    }
1215218
public static function encodeUri($uri)
    {
        $uri = self::removeSchemeFromUri($uri, $scheme);
        $uri = rawurlencode($uri);

        // Decode slashes
        $uri = str_replace("%2F", "/", $uri);

        return $scheme . $uri;
    }
527889
public function withUri(UriInterface $uri, $preserveHost = false)
        {
            $clone = clone $this;
            $clone->uri = $uri;
            $host = $uri->getHost();

            if (!$preserveHost) {
                $clone->headers['host'] = $this->setNotPreserveHost($host);
            } else {

                $headerHost = $this->getHeaderLine('Host');
                $clone->headers['host'] = $this->setPreserveHost($headerHost, $host);

            }
            return $clone;
        }
95133
public static function uriWithArguments(UriInterface $uri, array $arguments): UriInterface
    {
        $query = http_build_query($arguments, '', '&', PHP_QUERY_RFC3986);
        return $uri->withQuery($query);
    }
161615
private function isValidString($uri)
    {
        if (preg_match('/^[\\x00-\\x7F]*$/', $uri)) {
            return true;
        } elseif ($this->mode === self::MODE_RFC3986) {
            return false;
        }

        // Validate UTF-8 via regular expression to avoid mbstring dependency
        $pattern =
            '/^(?>
                [\x00-\x7F]+                       # ASCII
              | [\xC2-\xDF][\x80-\xBF]             # non-overlong 2-byte
              |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding over longs
              | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
              |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates
              |  \xF0[\x90-\xBF][\x80-\xBF]{2}     # planes 1-3
              | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
              |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16
            )*$/x';

        return (bool) preg_match($pattern, $uri);
    }
1256556
protected static boolean isRelativeUri(URI uri) {
        if (uri.isAbsolute())
            return false;
        String path = uri.normalize().getPath();
        if (path.length() == 0 /* isEmpty() is mustang API */)
            return false;
        if (!path.equals(uri.getPath())) // implicitly checks for embedded . and ..
            return false;
        if (path.startsWith("/") || path.startsWith("./") || path.startsWith("../"))
            return false;
        return true;
    }
1196623
public static function absolute_url($path, $base_url)
    {
        // check if path is an absolute URL
        if (preg_match('/^[fhtps]+:\/\//', $path)) {
            return $path;
        }

        // check if path is a content-id scheme
        if (strpos($path, 'cid:') === 0) {
            return $path;
        }

        $host_url = $base_url;
        $abs_path = $path;

        // cut base_url to the last directory
        if (strrpos($base_url, '/') > 7) {
            $host_url = substr($base_url, 0, strpos($base_url, '/', 7));
            $base_url = substr($base_url, 0, strrpos($base_url, '/'));
        }

        // $path is absolute
        if ($path[0] == '/') {
            $abs_path = $host_url.$path;
        }
        else {
            // strip './' because its the same as ''
            $path = preg_replace('/^\.\//', '', $path);

            if (preg_match_all('/\.\.\//', $path, $matches, PREG_SET_ORDER)) {
                $cnt = count($matches);
                while ($cnt--) {
                    if ($pos = strrpos($base_url, '/')) {
                        $base_url = substr($base_url, 0, $pos);
                    }
                    $path = substr($path, 3);
                }
            }

            $abs_path = $base_url.'/'.$path;
        }

        return $abs_path;
    }