diff options
author | Clark Tomlinson <fallen013@gmail.com> | 2014-08-26 09:40:56 -0400 |
---|---|---|
committer | Clark Tomlinson <fallen013@gmail.com> | 2014-08-28 13:53:45 -0400 |
commit | ba0e65753b82a91d5145955aee0624876dee3ce4 (patch) | |
tree | 225a389d8bfabe81b2478151a01473023dd28680 | |
parent | 910b827b9801d6f8429e01809b821b98216af813 (diff) | |
download | nextcloud-server-ba0e65753b82a91d5145955aee0624876dee3ce4.tar.gz nextcloud-server-ba0e65753b82a91d5145955aee0624876dee3ce4.zip |
Init vars with a value if none is provided
-rw-r--r-- | core/js/js.js | 1 | ||||
-rw-r--r-- | core/js/tests/specs/coreSpec.js | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js index 60f9cc11a58..2f02ccd04a8 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; |