Pagekit\Finder\Controller\FinderController::normalizePath PHP Method

normalizePath() protected method

Normalizes the given path
protected normalizePath ( string $path ) : string
$path string
return string
    protected function normalizePath($path)
    {
        $path = str_replace(['\\', '//'], '/', $path);
        $prefix = preg_match('|^(?P<prefix>([a-zA-Z]+:)?//?)|', $path, $matches) ? $matches['prefix'] : '';
        $path = substr($path, strlen($prefix));
        $parts = array_filter(explode('/', $path), 'strlen');
        $tokens = [];
        foreach ($parts as $part) {
            if ('..' === $part) {
                array_pop($tokens);
            } elseif ('.' !== $part) {
                array_push($tokens, $part);
            }
        }
        return $prefix . implode('/', $tokens);
    }