Skip to content

Commit

Permalink
Improve INTEGER_ARRAY_FROM_STRING to filter empty item
Browse files Browse the repository at this point in the history
  • Loading branch information
enxtur committed Nov 4, 2024
1 parent 485605e commit 243ac07
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libs/hpc-data/src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const INTEGER_ARRAY_FROM_STRING = new t.Type<number[], number[]>(
? t.success(v)
: t.failure(v, c);
} else if (typeof v === 'string') {
const nums = v.split(',');
const nums = v.split(',').filter((n) => n.trim() !== '');
return nums.every((n) => INTEGER_REGEX.test(n))
? t.success(nums.map((n) => parseInt(n)))
: t.failure(v, c);
Expand Down

0 comments on commit 243ac07

Please sign in to comment.