Skip to content

Commit

Permalink
Update Debugger::makeSafeName method
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Sep 18, 2022
1 parent 05acdb9 commit 9e3d60a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@ public function renderDebugbar() : string

public static function makeSafeName(string $name) : string
{
return \strtr(\trim(\strip_tags(\strtolower($name))), [' ' => '-']);
return \strtr(\trim(\strip_tags(\strtolower($name))), [
'·' => '-',
':' => '-',
'(' => '-',
')' => '-',
'/' => '-',
'\\' => '-',
' ' => '-',
]);
}

public static function convertSize(float | int $size) : string
Expand Down
5 changes: 4 additions & 1 deletion tests/DebuggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ public function testOptions() : void

public function testMakeSafeName() : void
{
self::assertSame('foo-bar-baz', Debugger::makeSafeName('Foo Bar <small>Baz</small> '));
self::assertSame(
'foo-bar--baz-',
Debugger::makeSafeName('Foo Bar <small>(Baz)</small> ')
);
}

public function testConvertSize() : void
Expand Down

0 comments on commit 9e3d60a

Please sign in to comment.