mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-29 08:40:42 +02:00
Fixed parent directory when one level deep
This commit is contained in:
@@ -22,6 +22,6 @@ class ParentDir extends ViewFunction
|
||||
explode('/', $path)
|
||||
)->filter()->slice(0, -1)->implode('/');
|
||||
|
||||
return empty($parentDir) ? '' : sprintf('?dir=%s', $parentDir);
|
||||
return empty($parentDir) ? '.' : sprintf('?dir=%s', $parentDir);
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,21 @@ use Tests\TestCase;
|
||||
|
||||
class ParentDirTest extends TestCase
|
||||
{
|
||||
public function test_it_can_get_the_parent_directory_from_a_path(): void
|
||||
public function test_it_can_get_the_parent_directory_when_one_level_deep(): void
|
||||
{
|
||||
$parentDir = new ParentDir($this->container, $this->config);
|
||||
|
||||
$this->assertEquals('.', $parentDir('foo'));
|
||||
}
|
||||
|
||||
public function test_it_can_get_the_parent_directory_when_two_levels_deep(): void
|
||||
{
|
||||
$parentDir = new ParentDir($this->container, $this->config);
|
||||
|
||||
$this->assertEquals('?dir=foo', $parentDir('foo/bar'));
|
||||
}
|
||||
|
||||
public function test_it_can_get_the_parent_directory_when_three_levels_deep(): void
|
||||
{
|
||||
$parentDir = new ParentDir($this->container, $this->config);
|
||||
|
||||
|
Reference in New Issue
Block a user