summaryrefslogtreecommitdiffstats
path: root/core/js/js.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-07-13 10:57:52 +0200
committerVincent Petry <pvince81@owncloud.com>2015-07-13 10:57:52 +0200
commit1b7d42c5691ffa21246022690f7688dda534c2dc (patch)
tree618014ae955e23a5951cd76d70bd156a98859e16 /core/js/js.js
parent1006ec56ceb2c7c5bc14a5401d46767cb4b72e6c (diff)
downloadnextcloud-server-1b7d42c5691ffa21246022690f7688dda534c2dc.tar.gz
nextcloud-server-1b7d42c5691ffa21246022690f7688dda534c2dc.zip
Fix OC.joinPaths with empty arguments
When empty arguments are given, the leading or trailing slash was not detected properly.
Diffstat (limited to 'core/js/js.js')
-rw-r--r--core/js/js.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/core/js/js.js b/core/js/js.js
index ff52c8f1f39..d701a37acbd 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -340,13 +340,23 @@ var OC={
return '';
}
var path = '';
- var lastArg = arguments[arguments.length - 1];
- var leadingSlash = arguments[0].charAt(0) === '/';
+ // convert to array
+ var args = Array.prototype.slice.call(arguments);
+ // discard empty arguments
+ args = _.filter(args, function(arg) {
+ return arg.length > 0;
+ });
+ if (args.length < 1) {
+ return '';
+ }
+
+ var lastArg = args[args.length - 1];
+ var leadingSlash = args[0].charAt(0) === '/';
var trailingSlash = lastArg.charAt(lastArg.length - 1) === '/';
var sections = [];
var i;
- for (i = 0; i < arguments.length; i++) {
- sections = sections.concat(arguments[i].split('/'));
+ for (i = 0; i < args.length; i++) {
+ sections = sections.concat(args[i].split('/'));
}
var first = !leadingSlash;
for (i = 0; i < sections.length; i++) {