Zend\Diactoros\Uri::filterPath PHP Method

filterPath() private method

Filters the path of a URI to ensure it is properly encoded.
private filterPath ( string $path ) : string
$path string
return string
    private function filterPath($path)
    {
        $path = preg_replace_callback('/(?:[^' . self::CHAR_UNRESERVED . ':@&=\\+\\$,\\/;%]+|%(?![A-Fa-f0-9]{2}))/u', [$this, 'urlEncodeChar'], $path);
        if (empty($path)) {
            // No path
            return $path;
        }
        if ($path[0] !== '/') {
            // Relative path
            return $path;
        }
        // Ensure only one leading slash, to prevent XSS attempts.
        return '/' . ltrim($path, '/');
    }