Init vars with a value if none is provided

This commit is contained in:
Clark Tomlinson 2014-08-26 09:40:56 -04:00
parent 910b827b98
commit ba0e65753b
2 changed files with 4 additions and 0 deletions

View File

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

View File

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