Skip to content

Commit

Permalink
Merge pull request #103 from owenvoke/bugfix/filter-svg
Browse files Browse the repository at this point in the history
feat: ignore files without SVG extension
  • Loading branch information
driesvints authored Nov 3, 2020
2 parents 55d62d7 + 53633e9 commit 309bb41
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public function registerComponents(): void
{
foreach ($this->sets as $set) {
foreach ($this->filesystem->allFiles($set['path']) as $file) {
if ($file->getExtension() !== 'svg') {
continue;
}

$path = array_filter(explode('/', Str::after($file->getPath(), $set['path'])));

Blade::component(
Expand Down
11 changes: 11 additions & 0 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ public function it_can_retrieve_an_icon_from_a_subdirectory()
$this->assertSame('solid.camera', $icon->name());
}

/** @test */
public function it_excludes_files_without_an_svg_extension()
{
$factory = $this->prepareSets();

$this->expectException(SvgNotFound::class);
$this->expectExceptionMessage('Svg by name "invalid-extension" from set "default" not found.');

$factory->svg('invalid-extension');
}

/** @test */
public function it_throws_an_exception_when_no_icon_is_found()
{
Expand Down
Empty file.

0 comments on commit 309bb41

Please sign in to comment.