Commit 330f4609 by Scott Tester

Implemented qiangxue's solution as it is much simpler.

parent 39265da4
......@@ -49,19 +49,15 @@ class BaseFileHelper
$parts = [];
foreach (explode($ds, $path) as $part) {
if ($part === '..' && !empty($parts) && end($parts) !== '..') {
if (array_pop($parts) === ".") {
$parts[] = '..';
}
} elseif (( $part === '.' || $part === '' ) && !empty($parts)) {
array_pop($parts);
} elseif ($part === '.' || $part === '' && !empty($parts)) {
continue;
} else {
$parts[] = $part;
}
}
if (count($parts) > 1 && $parts[0] === '.') {
array_shift($parts);
}
return implode($ds, $parts);
$path = implode($ds, $parts);
return $path === '' ? '.' : $path;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment