mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-08-03 05:02:54 +00:00
feature(util) add checkArgs
This commit is contained in:
parent
4a4ab12a5b
commit
d77ac56f0f
2 changed files with 30 additions and 7 deletions
|
|
@ -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 = '',
|
||||
|
|
|
|||
18
lib/util.js
18
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
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue