Remove instances of "./" and "../" where possible from a root-relative URI

@param string $uri

@return string
499002
public static function removeDots($uri)
    {
        $uri = str_replace('/./', '/', $uri);
        // inspired by patch from Oleg Cherniy
        do {
            $uri = preg_replace('@/[^/]+/\\.\\./@', '/', $uri, 1, $changed);
        } while ($changed);

        return $uri;
    }
364398
public static function sites(String $uri = NULL) : String
    {
        return str_replace(SSL_STATUS, Http::fix(true), self::site($uri));
    }
1219674
public function getUriLocale($uri)
    {
        $parts = explode('/', $uri);
        $locale = $parts[1];

        if (count($parts) < 2 || ! in_array($locale, $this->getLocales())) {
            return;
        }

        return $locale;
    }
1196397
public static String stripHost(final String uri)
        {
        if (!uri.startsWith("http")) 
            {
            // It's likely a URI path, not the full URI (i.e. the host is 
            // already stripped).
            return uri;
            }
        final String noHttpUri = StringUtils.substringAfter(uri, "://");
        final int slashIndex = noHttpUri.indexOf("/");
        if (slashIndex == -1)
            {
            return "/";
            }
        final String noHostUri = noHttpUri.substring(slashIndex);
        return noHostUri;
        }
1214990
private function toAbsoluteURI($uri)
    {
        list($pathBase, $scheme, $prePath) = $this->getPathInfo($this->configuration->getOriginalURL());

        // If this is already an absolute URI, return it.
        if (preg_match('/^[a-zA-Z][a-zA-Z0-9\+\-\.]*:/', $uri)) {
            return $uri;
        }

        // Scheme-rooted relative URI.
        if (substr($uri, 0, 2) === '//') {
            return $scheme . '://' . substr($uri, 2);
        }

        // Prepath-rooted relative URI.
        if (substr($uri, 0, 1) === '/') {
            return $prePath . $uri;
        }

        // Dotslash relative URI.
        if (strpos($uri, './') === 0) {
            return $pathBase . substr($uri, 2);
        }
        // Ignore hash URIs:
        if (substr($uri, 0, 1) === '#') {
            return $uri;
        }

        // Standard relative URI; add entire path. pathBase already includes a
        // trailing "/".
        return $pathBase . $uri;
    }
18639
public static function uriToPath(string $uri)
    {
        $fragments = parse_url($uri);
        if ($fragments === false || !isset($fragments['scheme']) || $fragments['scheme'] !== 'file') {
            throw new \InvalidArgumentException("Not a valid file URI: $uri");
        }
        $filepath = urldecode((string) $fragments['path']);
        if (strpos($filepath, ':') !== false) {
            if ($filepath[0] === '/') {
                $filepath = substr($filepath, 1);
            }
            $filepath = str_replace('/', '\\', $filepath);
        }
        return $filepath;
    }
131530
public function findURI(string $uri)
    {
        foreach ($this->members as $offset => $member) {
            if ($member->uri == $uri) {
                return $offset;
            }
        }
        return -1;
    }
1272008
public static function releaseUri($uri)
    {
        if ($uri instanceof StreamInterface) {
            $uri = 'spiral://' . spl_object_hash($uri);
        }

        unset(self::$uris[$uri]);
    }
473153
public static function removeZoneId($uri)
    {
        return $uri->withHost((string) (new Host(self::filterUri($uri)->getHost()))->withoutZoneIdentifier());
    }
969296
public function resolveAssetUri(string $uri): ?string
    {
        $targetObject = $this->convertUriToObject($uri);
        if ($targetObject === null) {
            $this->systemLogger->info(sprintf('Could not resolve "%s" to an existing asset; The asset was probably deleted.', $uri), LogEnvironment::fromMethodName(__METHOD__));
            return null;
        }
        return $this->resourceManager->getPublicPersistentResourceUri($targetObject->getResource());
    }
1202136
public function unlink($uri)
    {
        $this->uri = $uri;

        return $this->invoke($this->getFilesystem(), 'delete', [$this->getTarget()], 'unlink');
    }
466856
protected function removeUriQueryArguments($redirectUri)
    {
        $uri = new \Neos\Flow\Http\Uri($redirectUri);
        $uri->setQuery(null);
        $redirectUri = (string)$uri;

        return $redirectUri;
    }
284519
protected function processUri($uri)
    {
        return preg_replace_callback('#\{([a-zA-Z0-9_,]*)\}#i', function ($matches) {
            return isset($this->tokens[$matches[1]]) ? $this->tokens[$matches[1]] : '';
        }, $uri);
    }
1151679
static public function removePathPrefixFromURI($uriString)
    {
        $ini = eZINI::instance();

        $prefix = self::getPathPrefix();
        if ( !$prefix )
        {
            return $uriString;
        }

        $exclude = $ini->hasVariable( 'SiteAccessSettings', 'PathPrefixExclude' )
            ? $ini->variable( 'SiteAccessSettings', 'PathPrefixExclude' )
            : false;
        foreach ( $exclude as $item )
        {
            $escapedItem = preg_quote( $item, '#' );
            if ( preg_match( "#^$escapedItem(/.*)?$#i", $uriString ) )
            {
                return $uriString;
            }
        }

        $escapedPrefix = preg_quote( $prefix, '#' );
        $modifiedUriString = preg_replace( "#^$escapedPrefix/?#i", '', $uriString );
        return $modifiedUriString === null ? $uriString : $modifiedUriString;
    }
437845
public static function hostToAscii($uri)
    {
        return $uri->withHost((string) (new Host(self::filterUri($uri)->getHost())));
    }
976168
public function resolveAlias($uri)
    {
        $this->normalizeUri($uri, $name);

        return $this->resolveRawAlias($uri)['alias'] ?? $uri;
    }
1217686
public static function getAbsoluteUri(string $uri = null) : string
    {
        $uri = new self($uri);

        return $uri->get(false);
    }