Fixed breadcrumbs not returning crubs for directories with names that exist in the application base_path

This commit is contained in:
Chris Kankiewicz
2021-09-22 16:57:32 -07:00
parent c09243fb63
commit 09a78e2fc2
2 changed files with 3 additions and 2 deletions

View File

@@ -29,7 +29,7 @@ class Breadcrumbs extends ViewFunction
/** Build a collection of breadcrumbs for a given path. */
public function __invoke(string $path): Collection
{
return Str::explode($path, $this->directorySeparator)->diff(
return Str::explode($path, $this->directorySeparator)->diffAssoc(
explode($this->directorySeparator, $this->config->get('base_path'))
)->filter(static function (string $crumb): bool {
return ! in_array($crumb, [null, '.']);

View File

@@ -17,7 +17,8 @@ class BreadcrumbsTest extends TestCase
'foo' => '?dir=foo',
'bar' => '?dir=foo/bar',
'baz' => '?dir=foo/bar/baz',
]), $breadcrumbs('foo/bar/baz'));
'tests' => '?dir=foo/bar/baz/tests',
]), $breadcrumbs('foo/bar/baz/tests'));
}
public function test_it_can_parse_breadcrumbs_for_dot_path(): void