Skip to content
Snippets Groups Projects
Commit ed2424c3 authored by Thomas Müller's avatar Thomas Müller
Browse files

Merge pull request #10637 from owncloud/fixing-js-issues

Init vars with a value if none is provided
parents 745ec120 ba0e6575
No related branches found
No related tags found
No related merge requests found
...@@ -234,6 +234,7 @@ var OC={ ...@@ -234,6 +234,7 @@ var OC={
*/ */
generateUrl: function(url, params) { generateUrl: function(url, params) {
var _build = function (text, vars) { var _build = function (text, vars) {
var vars = vars || [];
return text.replace(/{([^{}]*)}/g, return text.replace(/{([^{}]*)}/g,
function (a, b) { function (a, b) {
var r = vars[b]; var r = vars[b];
......
...@@ -376,6 +376,9 @@ describe('Core base tests', function() { ...@@ -376,6 +376,9 @@ describe('Core base tests', function() {
it('substitutes parameters', 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'); 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() { describe('Main menu mobile toggle', function() {
var clock; var clock;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment