fix: error in toArrayConfig

If an empty string or undefined is provided the method should not return [], but undefined instead. This way defaults defined in Joi function as expected.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-03-16 20:13:41 +01:00
parent 5db2229771
commit 91d7f1a529
4 changed files with 19 additions and 15 deletions

View file

@ -5,9 +5,12 @@
*/
import { Loglevel } from './loglevel.enum';
export function toArrayConfig(configValue?: string, separator = ','): string[] {
export function toArrayConfig(
configValue?: string,
separator = ',',
): string[] | undefined {
if (!configValue) {
return [];
return undefined;
}
if (!configValue.includes(separator)) {
return [configValue.trim()];