From 77ea05a23339110d2f63c04c6709c185b8c9805e Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Wed, 19 May 2021 01:46:12 -0400 Subject: [PATCH] also handle arrays of strings --- server/config.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/config.js b/server/config.js index 971ede73..0cea3996 100644 --- a/server/config.js +++ b/server/config.js @@ -11,8 +11,9 @@ convict.addFormat({ throw new Error('must be a comma-separated list of positive integers') } }, - coerce: (ints_str, schema) => { - return ints_str.trim().split(',').map(int_str => parseInt(int_str.trim(), 10)) + coerce: (ints, schema) => { + const ints_arr = Array.isArray(ints_str) ? ints : ints.trim().split(',') + return ints_arr.map(int => (typeof int === 'number') ? int : parseInt(int.trim(), 10)) }, });