diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-07-13 17:25:27 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-07-13 17:25:27 +0200 |
commit | e18d0e26f6b5fbef555acacb7d1ec7adbff1c50e (patch) | |
tree | 1aec97acc15c3d2e3067f86f753ce7d7d864f015 /core/js/js.js | |
parent | e4ed99572756dec2634ca0d18b0b78e97bb613ef (diff) | |
parent | 1b7d42c5691ffa21246022690f7688dda534c2dc (diff) | |
download | nextcloud-server-e18d0e26f6b5fbef555acacb7d1ec7adbff1c50e.tar.gz nextcloud-server-e18d0e26f6b5fbef555acacb7d1ec7adbff1c50e.zip |
Merge pull request #17599 from owncloud/fix-joinpaths-trailingslash
Fix OC.joinPaths with empty arguments
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/core/js/js.js b/core/js/js.js index 1dfcb576c2a..ba456b54c6d 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -385,13 +385,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++) { |