aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-08-29 10:16:29 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-08-29 10:16:29 +0200
commited2424c3822a3470065788ff113a3807d24d80dc (patch)
tree891d79e5437dfb010361c83bb54de536286a8a71
parent745ec1200253a35438b5fe1a392f839c9f7d8336 (diff)
parentba0e65753b82a91d5145955aee0624876dee3ce4 (diff)
downloadnextcloud-server-ed2424c3822a3470065788ff113a3807d24d80dc.tar.gz
nextcloud-server-ed2424c3822a3470065788ff113a3807d24d80dc.zip
Merge pull request #10637 from owncloud/fixing-js-issues
Init vars with a value if none is provided
-rw-r--r--core/js/js.js1
-rw-r--r--core/js/tests/specs/coreSpec.js3
2 files changed, 4 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 2b3107ecbbf..9a60b0aad69 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -234,6 +234,7 @@ var OC={
*/
generateUrl: function(url, params) {
var _build = function (text, vars) {
+ var vars = vars || [];
return text.replace(/{([^{}]*)}/g,
function (a, b) {
var r = vars[b];
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index 166210d0312..3af56c490e6 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -376,6 +376,9 @@ describe('Core base tests', function() {
it('substitutes parameters', function() {
expect(OC.generateUrl('apps/files/download{file}', {file: '/Welcome.txt'})).toEqual(OC.webroot + '/index.php/apps/files/download/Welcome.txt');
});
+ it('doesnt error out with no params provided', function () {
+ expect(OC.generateUrl('apps/files/download{file}')).toEqual(OC.webroot + '/index.php/apps/files/download{file}');
+ });
});
describe('Main menu mobile toggle', function() {
var clock;