Skip to content

Commit

Permalink
Strip trailing slash from path
Browse files Browse the repository at this point in the history
Fixes #79
  • Loading branch information
mvdnbrk committed Sep 4, 2020
1 parent b47ad40 commit 91dc18f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Factory.php
Expand Up @@ -54,6 +54,8 @@ public function add(string $set, array $options): self
throw CannotRegisterIconSet::prefixNotUnique($set, $collidingSet);
}

$options['path'] = rtrim($options['path'], '/');

if ($this->filesystem->missing($options['path'])) {
throw CannotRegisterIconSet::nonExistingPath($set, $options['path']);
}
Expand Down
13 changes: 13 additions & 0 deletions tests/FactoryTest.php
Expand Up @@ -249,6 +249,19 @@ public function it_throws_an_exception_when_no_icon_is_found()
$factory->svg('money');
}

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

$factory->add('default', [
'path' => __DIR__ . '/resources/svg/',
'prefix' => '',
]);

$this->assertSame(__DIR__ . '/resources/svg', $factory->all()['default']['path']);
}

protected function getPackageProviders($app): array
{
return [BladeIconsServiceProvider::class];
Expand Down

0 comments on commit 91dc18f

Please sign in to comment.