Skip to content

Commit 43710fe

Browse files
committed
Fixed prefix trimmer to correctly handle paths
1 parent c833746 commit 43710fe

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/OpCacheGUI/Format/Prefix.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,18 @@ private function getPrefixLength(array $scripts)
7676
*/
7777
private function findLongestPrefix($prefix, $path)
7878
{
79-
$prefixChars = str_split($prefix);
80-
$pathChars = str_split($path);
79+
$prefixChars = str_split(str_replace('\\', '/', $prefix));
80+
$pathChars = str_split(str_replace('\\', '/', $path));
81+
82+
$lastSlash = 0;
8183

8284
foreach ($prefixChars as $index => $char) {
85+
if ($char === '/') {
86+
$lastSlash = $index;
87+
}
88+
8389
if ($char !== $pathChars[$index]) {
84-
return mb_substr($prefix, 0, $index);
90+
return mb_substr($prefix, 0, $lastSlash);
8591
}
8692
}
8793

0 commit comments

Comments
 (0)