Skip to content

Commit 3b76ca0

Browse files
committed
Fixes ncorrect paths shown when run from root file system directory (#98)
1 parent 467b31d commit 3b76ca0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Error.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ public function getFilePath()
6969
*/
7070
public function getShortFilePath()
7171
{
72-
return str_replace(getcwd(), '', $this->filePath);
72+
$cwd = getcwd();
73+
74+
if ($cwd === '/') {
75+
// For root directory in unix, do not modify path
76+
return $this->filePath;
77+
}
78+
79+
return preg_replace('/' . preg_quote($cwd, '/') . '/', '', $this->filePath, 1);
7380
}
7481

7582
/**

0 commit comments

Comments
 (0)