mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-25 23:06:39 +02:00
Fixed incorrect breadcrumbs when path contains a directory named '0'
This commit is contained in:
@@ -39,19 +39,15 @@ class Breadcrumbs extends ViewFunction
|
||||
*/
|
||||
public function __invoke(string $path)
|
||||
{
|
||||
$breadcrumbs = Str::explode($path, $this->directorySeparator)->diff(
|
||||
return Str::explode($path, $this->directorySeparator)->diff(
|
||||
explode($this->directorySeparator, $this->container->get('base_path'))
|
||||
)->filter(function ($value): bool {
|
||||
return $value !== null;
|
||||
});
|
||||
|
||||
return $breadcrumbs->filter(function (string $crumb) {
|
||||
return $crumb !== '.';
|
||||
})->reduce(function (Collection $carry, string $crumb) {
|
||||
)->filter(function (string $crumb): bool {
|
||||
return ! in_array($crumb, [null, '.']);
|
||||
})->reduce(function (Collection $carry, string $crumb): Collection {
|
||||
return $carry->put($crumb, ltrim(
|
||||
$carry->last() . $this->directorySeparator . rawurlencode($crumb), $this->directorySeparator
|
||||
));
|
||||
}, new Collection)->map(function (string $path): string {
|
||||
}, new Collection)->map(function (string $path, string $name): string {
|
||||
return sprintf('?dir=%s', $path);
|
||||
});
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
{{ translate('home') }}
|
||||
</a>
|
||||
|
||||
{% if path %}
|
||||
{% if path is not null %}
|
||||
{% for name, path in breadcrumbs(path) %}
|
||||
/ <a href="{{ path }}" class="inline-block hover:underline">{{ name }}</a>
|
||||
{% endfor %}
|
||||
|
Reference in New Issue
Block a user