summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-08-30 14:02:50 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-08-30 14:02:50 +0200
commit66f2b155cecbd6b066fbc6c1efa7317e24f79915 (patch)
treedaade718de3edbff93b71df4ad805319d0227312 /core/js
parent4508a121881d5aef31479a96a11cab4783ac48ee (diff)
downloadnextcloud-server-66f2b155cecbd6b066fbc6c1efa7317e24f79915.tar.gz
nextcloud-server-66f2b155cecbd6b066fbc6c1efa7317e24f79915.zip
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>
Diffstat (limited to 'core/js')
-rw-r--r--core/js/oc-dialogs.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index d346b5231d1..a9f9426c488 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -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) {