config/validator: fix lists.

This commit is contained in:
Christopher Jeffrey 2017-03-14 06:16:57 -07:00
parent 544836de3d
commit 74b21b78c5
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 28 additions and 2 deletions

View File

@ -370,6 +370,7 @@ Config.prototype.buf = function buf(key, fallback) {
Config.prototype.array = function array(key, fallback) {
var value = this.get(key);
var i, result, parts, part;
if (fallback === undefined)
fallback = null;
@ -383,7 +384,19 @@ Config.prototype.array = function array(key, fallback) {
return value;
}
return value.trim().split(/\s*,\s*/);
parts = value.trim().split(/\s*,\s*/);
result = [];
for (i = 0; i < parts.length; i++) {
part = parts[i];
if (part.length === 0)
continue;
result.push(part);
}
return result;
};
/**

View File

@ -466,6 +466,7 @@ Validator.prototype.buf = function buf(key, fallback, enc) {
Validator.prototype.array = function array(key, fallback) {
var value = this.get(key);
var i, result, parts, part;
if (fallback === undefined)
fallback = null;
@ -479,7 +480,19 @@ Validator.prototype.array = function array(key, fallback) {
return value;
}
return value.trim().split(/\s*,\s*/);
parts = value.trim().split(/\s*,\s*/);
result = [];
for (i = 0; i < parts.length; i++) {
part = parts[i];
if (part.length === 0)
continue;
result.push(part);
}
return result;
};
/**