mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-09-01 18:03:29 +02:00
Parse any file named README as long as it's a text file
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
Reference in New Issue
Block a user