mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-09-02 02:12:37 +02:00
Improved hidden file filtering to prevent hidden files from showing up in search results
This commit is contained in:
@@ -3,7 +3,6 @@ DARK_MODE=false
|
||||
SORT_ORDER=type
|
||||
REVERSE_SORT=false
|
||||
|
||||
HIDDEN_FILES=""
|
||||
HIDE_APP_FILES=true
|
||||
HIDE_VCS_FILES=true
|
||||
|
||||
|
@@ -53,7 +53,13 @@ class FinderComposer
|
||||
$finder = Finder::create()->followLinks();
|
||||
$finder->ignoreVCS($this->config->get('app.hide_vcs_files', false));
|
||||
$finder->filter(function (SplFileInfo $file) {
|
||||
return ! $this->hiddenFiles()->contains($file->getRealPath());
|
||||
foreach ($this->hiddenFiles() as $hiddenPath) {
|
||||
if (strpos($file->getRealPath(), $hiddenPath) === 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
$sortOrder = $this->config->get('app.sort_order', 'type');
|
||||
@@ -93,6 +99,6 @@ class FinderComposer
|
||||
);
|
||||
})->flatten()->map(function (string $file) {
|
||||
return realpath($file);
|
||||
});
|
||||
})->unique();
|
||||
}
|
||||
}
|
||||
|
@@ -24,9 +24,9 @@ return [
|
||||
*
|
||||
* Default value: []
|
||||
*/
|
||||
'hidden_files' => array_map(function (string $file) {
|
||||
return trim($file);
|
||||
}, explode(',', Helpers::env('HIDDEN_FILES'))),
|
||||
'hidden_files' => [
|
||||
// ...
|
||||
],
|
||||
|
||||
/**
|
||||
* Whether or not to hide application files/directories form the listing.
|
||||
|
Reference in New Issue
Block a user