From 8c9b160a56c4dfb85ad401fb999ac314c5896759 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Tue, 7 Jan 2020 13:13:00 -0700 Subject: [PATCH] Parse any file named README as long as it's a text file --- app/Controllers/DirectoryController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Controllers/DirectoryController.php b/app/Controllers/DirectoryController.php index 90d708c..53c3e3e 100644 --- a/app/Controllers/DirectoryController.php +++ b/app/Controllers/DirectoryController.php @@ -139,7 +139,10 @@ class DirectoryController */ protected function readme($path): SplFileInfo { - $readmes = Finder::create()->in($path)->depth(0)->name('/^README\.(?:md|txt)$/i'); + $readmes = Finder::create()->in($path)->depth(0)->name('/^README(?:\..+)?$/i'); + $readmes->filter(function (SplFileInfo $file) { + return (bool) preg_match('/text\/.+/', mime_content_type($file->getPathname())); + }); $readmes->sort(function (SplFileInfo $file1, SplFileInfo $file2) { return $file1->getExtension() <=> $file2->getExtension(); });