Provide filter to trim trailing slashes in URI path

@deprecated
@param  \Psr\Http\Message\UriInterface $uri
@return string
559327
protected function filterTrailingSlash(UriInterface $uri)
    {
        $path = $uri->getPath();

        if (strlen($path) > 1 && substr($path, -1) === '/') {
            $path = substr($path, 0, -1);
        }

        return $path;
    }
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;
    }
1219674
public function getUriLocale($uri)
    {
        $parts = explode('/', $uri);
        $locale = $parts[1];

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

        return $locale;
    }
1355734
private function cleanupQuery(string $uri): string
    {
        if (false !== $pos = strpos($uri, '?')) {
            return substr($uri, 0, $pos);
        }

        return $uri;
    }
387852
public static function datapathToAscii($uri)
    {
        return $uri->withPath((string) (new DataPath(self::filterUri($uri)->getPath()))->toAscii());
    }
694001
private function getURI()
    {
        if (!empty($_SERVER['PATH_INFO'])) {
            $uri = $_SERVER['PATH_INFO'];
        } elseif (!empty($_SERVER['REQUEST_URI'])) {
            $uri = $_SERVER['REQUEST_URI'];
        } else {
            $uri = false;
        }

        if ($uri === '/') {
            $uri = false;
        }

        return trim(preg_replace('/\?.*/', '', $uri), '/');
    }
617372
public function parse($uri)
    {
        preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);

        $components = array();
        if (5 < count($match)) {
            $components =  array(
                'scheme'    => $match[2],
                'authority' => $match[4],
                'path'      => $match[5]
            );
        }
        if (7 < count($match)) {
            $components['query'] = $match[7];
        }
        if (9 < count($match)) {
            $components['fragment'] = $match[9];
        }

        return $components;
    }
205237
protected function getAdditionalUriData($uri)
    {
        if (strpos($uri, '?') !== false) {
            return substr($uri, strpos($uri, '?'));
        } else if (strpos($uri, '#') !== false) {
            return substr($uri, strpos($uri, '#'));
        }
        
        return '';
    }
808293
public function toContainer(string $uri = ''): string
    {
        $uri = $uri ? $this->c::mbLTrim($uri, '/') : '';
        $uri = $uri ? '/'.$uri : ''; // Force leading slash.

        return $url = 'https://'.$this->App::CORE_CONTAINER_DOMAIN.$uri;
    }
72350
private function parseUri(string $uri): array
    {
        $defaults = [
            'scheme'   => '',
            'host'     => '',
            'port'     => '',
            'user'     => '',
            'pass'     => '',
            'path'     => '',
            'query'    => '',
            'fragment' => '',
        ];

        if (0 === strpos($uri, 'file://')) {
            // parse_url botches this up
            preg_match('@file://(?P<path>[^#]*)(?P<fragment>#.*)?@', $uri, $matches);

            return array_merge($defaults, array_intersect_key($matches, $defaults));
        }

        return array_merge($defaults, array_intersect_key(parse_url($uri), $defaults));
    }
1197553
private function abridgeUri($uri)
    {
        $i = 30;
        $j = 12;

        if (mb_strlen($uri) <= $i) {
            return $uri;
        }

        $host = rtrim(parse_url($uri, PHP_URL_HOST), '/');
        $path = '/'.ltrim(parse_url($uri, PHP_URL_PATH), '/');

        if ($host === getenv('HTTP_HOST')) {
            $i = 50;
            $j = 22;

            $host = '';
        } else {
            if (mb_strlen($host) > $i && mb_strlen($path) > $i) {
                return $this->abridgeStr($uri, 50, 22);
            }

            $host = $this->abridgeStr($host, 20, 7);
        }

        $path = $this->abridgeStr($path, $i, $j);

        return $host.$path;
    }
183346
public function uriToClassName(string $uri): string 
    {
        $string_parts = explode("-", $uri);
        $string = array_map('ucfirst', $string_parts);
        $string = implode("", $string) . "Controller"; 
        return preg_replace("/[^a-zA-Z0-9\-]/", "", $string);
    }
537348
public static function replaceExtension($uri, $extension)
    {
        $uri = self::filterUri($uri);

        return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withExtension($extension));
    }
1327003
public static function get_rest_path($uri=false) {
        if ( ! $uri ) $uri = $_SERVER['REQUEST_URI'];     // /tsugi/lti/some/cool/stuff
        $pos = strpos($uri,'?');
        if ( $pos > 0 ) $uri = substr($uri,0,$pos);
        if ( self::endsWith($uri, '/') ) {
            $uri = substr($uri, 0, strlen($uri)-1);
        }
        return $uri;
    }
939148
private function uriTrim() {
		$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
		$uri = trim($uri, '/\^$');
		if(strpos($uri,'?')) $uri = substr($uri,0,strpos($uri,'?'));
		return $uri;
	}
208378
public static function addLeadingSlash($uri)
    {
        $uri = self::filterUri($uri);
        $path = $uri->getPath();
        if ('/' !== ($path[0] ?? '')) {
            $path = '/'.$path;
        }

        return self::normalizePath($uri, $path);
    }
1315359
protected function _remove_http_query( $uri ) {
		$uri = str_replace( http_build_query( $_GET, null, '&' ), '', $uri );
		$uri = rtrim( $uri, '?' );
		return $uri;
	}