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);
}