Webiny\Component\Storage\Driver\Local\LocalHelper::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 = $this->getAbsolutePrefix($path);
        $path = substr($path, strlen($prefix));
        $parts = array_filter(explode('/', $path), 'strlen');
        $tokens = array();
        foreach ($parts as $part) {
            switch ($part) {
                case '.':
                    continue;
                    break;
                case '..':
                    if (count($tokens) !== 0) {
                        array_pop($tokens);
                        continue;
                    } elseif (!empty($prefix)) {
                        continue;
                    }
                    break;
                default:
                    $tokens[] = $part;
            }
        }
        return $prefix . implode('/', $tokens);
    }