File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,9 +64,6 @@ public static function normalizePath(string|false|null $path): string
6464 return str_replace ('\\' , '/ ' , $ path );
6565 }
6666
67- /**
68- * Resolves dot-dot (..) relative segments in a path without hitting the disk.
69- */
7067 public static function canonicalizePath (string $ path ): string
7168 {
7269 $ path = str_replace ('\\' , '/ ' , $ path );
@@ -79,14 +76,15 @@ public static function canonicalizePath(string $path): string
7976
8077 foreach ($ parts as $ part ) {
8178 if ($ part === '. ' || $ part === '' ) {
82- if ($ part === '' && empty ($ absolutes )) {
79+ if ($ part === '' && \count ($ absolutes ) === 0 ) {
8380 $ absolutes [] = '' ;
8481 }
82+
8583 continue ;
8684 }
8785
8886 if ($ part === '.. ' ) {
89- if (! empty ($ absolutes ) && end ($ absolutes ) !== '.. ' ) {
87+ if (\count ($ absolutes ) > 0 && end ($ absolutes ) !== '.. ' ) {
9088 array_pop ($ absolutes );
9189 } else {
9290 $ absolutes [] = '.. ' ;
You can’t perform that action at this time.
0 commit comments