From 0e37e3acdbd213d1a95829b6c04596ab569218ae Mon Sep 17 00:00:00 2001 From: Gerben Date: Sun, 18 Dec 2022 14:51:48 +0100 Subject: [PATCH] Serve index.html when requested path is a directory. --- lib/Controller/RawResponse.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Controller/RawResponse.php b/lib/Controller/RawResponse.php index 99ebdfa..c3e238c 100644 --- a/lib/Controller/RawResponse.php +++ b/lib/Controller/RawResponse.php @@ -6,8 +6,12 @@ use \Exception; trait RawResponse { protected function returnRawResponse($fileNode) { if ($fileNode->getType() === 'dir') { - // Is there some reasonable thing to return for a directory? An html index? A tarball? - throw new Exception("Requested share is a directory, not a file."); + // If the requested path is a folder, try return its index.html. + try { + $fileNode = $fileNode->get('index.html'); + } catch (NotFoundException $e) { + return new NotFoundResponse(); + } } $content = $fileNode->getContent();