Skip to content

Commit 0c0f9d4

Browse files
VasekPurchartdg
authored andcommitted
BlueScreen: collapse paths usable with files [Closes #115]
1 parent e8be759 commit 0c0f9d4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Tracy/BlueScreen.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,10 @@ public static function highlightLine($html, $line, $lines = 15)
177177
*/
178178
public function isCollapsed($file)
179179
{
180+
$file = strtr($file, '\\', '/') . '/';
180181
foreach ($this->collapsePaths as $path) {
181-
if (strpos(strtr($file, '\\', '/'), strtr("$path/", '\\', '/')) === 0) {
182+
$path = strtr($path, '\\', '/') . '/';
183+
if (strncmp($file, $path, strlen($path)) === 0) {
182184
return TRUE;
183185
}
184186
}

tests/Tracy/Bluescreen.collapsedPaths.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ require __DIR__ . '/../bootstrap.php';
1313
$blueScreen = new Tracy\BlueScreen;
1414

1515
$blueScreen->collapsePaths[] = __DIR__;
16+
$blueScreen->collapsePaths[] = dirname(__DIR__) . '/bootstrap.php';
1617

1718
Assert::true($blueScreen->isCollapsed(__FILE__));
19+
Assert::true($blueScreen->isCollapsed(dirname(__DIR__) . '/bootstrap.php'));
20+
Assert::false($blueScreen->isCollapsed(dirname(__DIR__) . '/bootstrap.php.tmp'));
1821
Assert::false($blueScreen->isCollapsed(dirname(__DIR__) . 'somethingElse'));
22+
Assert::false($blueScreen->isCollapsed(__DIR__ . '-dir'));

0 commit comments

Comments
 (0)