Skip to content

Commit

Permalink
Icon deferring; match all SVG tags (#244)
Browse files Browse the repository at this point in the history
* Icon deferring; match all SVG tags

* Don't use the helper

* Use __toString()
  • Loading branch information
royduin authored Jul 26, 2024
1 parent c9c45a4 commit 99783fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use BladeUI\Icons\Concerns\RendersAttributes;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Str;

final class Svg implements Htmlable
{
Expand Down Expand Up @@ -50,7 +51,10 @@ protected function deferContent(string $contents, $defer = false): string
return $contents;
}

$svgContent = strip_tags($contents, ['circle', 'ellipse', 'line', 'path', 'polygon', 'polyline', 'rect', 'g', 'mask', 'defs', 'use']);
$svgContent = Str::of($contents)
->replaceMatches('/<svg[^>]*>/', '')
->replaceMatches('/<\/svg>/', '')
->__toString();

// Force Unix line endings for hash.
$hashContent = str_replace(PHP_EOL, "\n", $svgContent);
Expand Down

0 comments on commit 99783fe

Please sign in to comment.