diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 5eec4071..06d6357e 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -327,13 +327,18 @@ var Util; * @param url - адрес каталога */ function getPathLink(url, template) { - var pathHTML = '', - path = '/', - namesRaw = url.split('/') - .slice(1, -1), - names = [].concat('/', namesRaw), - - length = names.length - 1; + var namesRaw, names, length, + pathHTML = '', + path = '/'; + + Util.checkArgs(arguments, ['url', 'template']); + + namesRaw = url.split('/') + .slice(1, -1), + + names = [].concat('/', namesRaw), + + length = names.length - 1; names.forEach(function(name, index) { var slash = '', diff --git a/lib/util.js b/lib/util.js index 8949f427..aa930834 100644 --- a/lib/util.js +++ b/lib/util.js @@ -59,6 +59,24 @@ return !!isMatch; }; + this.checkArgs = function(argsParam, names) { + var error, + msg = '', + i = 0, + n = names.length, + template = '{{ name }} coud not be empty!'; + + for (i = 0; i < n; i++) + if (!argsParam[i]) { + msg = Util.render(template, { + name: names[i] + }); + + error = new Error(msg); + throw(error); + } + }; + /** * Check is Properties exists and they are true if neaded *