Browse Source

Fix empty mime type filter

When the mime type is an empty array no filter should be applied.
However, the filter was loosely compared to an empty array, but as
arrays are objects then it became an implicit strict equality comparison
which always failed due to being different objects. Now the length of
the array is compared instead, and also moved outside the loop as it is
not needed to check it for each file.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
tags/v14.0.0RC2
Daniel Calviño Sánchez 5 years ago
parent
commit
66f2b155ce
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      core/js/oc-dialogs.js

+ 2
- 2
core/js/oc-dialogs.js View File

@@ -841,9 +841,9 @@ var OCdialogs = {
filter = [filter];
}
self.filepicker.filesClient.getFolderContents(dir).then(function(status, files) {
if (filter) {
if (filter && filter.length > 0) {
files = files.filter(function (file) {
return filter == [] || file.type === 'dir' || filter.indexOf(file.mimetype) !== -1;
return file.type === 'dir' || filter.indexOf(file.mimetype) !== -1;
});
}
files = files.sort(function(a, b) {

Loading…
Cancel
Save