protected function normalizeRelativePath($path)
{
// Path remove self referring paths ("/./").
$path = preg_replace('#/\\.(?=/)|^\\./|/\\./?$#', '', $path);
// Regex for resolving relative paths
$regex = '#/*[^/\\.]+/\\.\\.#Uu';
while (preg_match($regex, $path)) {
$path = preg_replace($regex, '', $path);
}
return $path;
}