Init vars with a value if none is provided

remotes/origin/fix-10825
Clark Tomlinson 12 years ago
parent 910b827b98
commit ba0e65753b
  1. 1
      core/js/js.js
  2. 3
      core/js/tests/specs/coreSpec.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];

@ -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;

Loading…
Cancel
Save