Improved hidden file filtering to prevent hidden files from showing up in search results

This commit is contained in:
Chris Kankiewicz
2020-01-05 17:06:43 -07:00
parent 6f629bda0e
commit 76a254ce6f
3 changed files with 11 additions and 6 deletions

View File

@@ -3,7 +3,6 @@ DARK_MODE=false
SORT_ORDER=type
REVERSE_SORT=false
HIDDEN_FILES=""
HIDE_APP_FILES=true
HIDE_VCS_FILES=true

View File

@@ -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();
}
}

View File

@@ -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.