From 63c62dc9582354342fa8e0c4c3bb41b698aeee24 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sat, 29 Jun 2024 10:34:40 +0200 Subject: [PATCH] Fix: Return Basename instead of Filename --- app/Fileshare/Data/ResourceData.php | 2 +- tests/Fileshare/FileshareFilesActionTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/Fileshare/Data/ResourceData.php b/app/Fileshare/Data/ResourceData.php index 15e78442..ccc9073a 100644 --- a/app/Fileshare/Data/ResourceData.php +++ b/app/Fileshare/Data/ResourceData.php @@ -17,7 +17,7 @@ class ResourceData extends Data return self::from([ 'path' => $dir, - 'name' => pathinfo($dir, PATHINFO_FILENAME), + 'name' => pathinfo($dir, PATHINFO_BASENAME), 'parent' => pathinfo($dir, PATHINFO_DIRNAME), ]); } diff --git a/tests/Fileshare/FileshareFilesActionTest.php b/tests/Fileshare/FileshareFilesActionTest.php index 05ef83d1..d16ce8b3 100644 --- a/tests/Fileshare/FileshareFilesActionTest.php +++ b/tests/Fileshare/FileshareFilesActionTest.php @@ -64,4 +64,17 @@ class FileshareFilesActionTest extends FileshareTestCase ->assertJsonPath('data.0.path', '/lala/dd/ee') ->assertJsonPath('data.0.parent', '/lala/dd'); } + + public function testItGetsFilesWithDot(): void + { + $this->withoutExceptionHandling()->login()->loginNami()->withOwncloudUser('badenpowell', 'secret') + ->withDirs('badenpowell', ['/1. aa']); + + $connection = Fileshare::factory() + ->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')])) + ->create(); + + $this->postJson(route('api.fileshare.files', ['fileshare' => $connection]), ['parent' => '/']) + ->assertJsonPath('data.0.name', '1. aa'); + } }