diff --git a/index.ts b/index.ts index ca9654e..f6fb5dd 100644 --- a/index.ts +++ b/index.ts @@ -1452,9 +1452,11 @@ export class RFC5424 extends RFC { return '[' + [ sdId, ...Object.entries(sdParam) - .map(([name, value]) => - `${name}="${RFC5424.escapeParamValue(value)}"` - ), + .reduce((array, [name, value]) => [ + ...array, + ...(Array.isArray(value) ? value : [value]) + .map((v) => `${name}="${RFC5424.escapeParamValue(v)}"`), + ], []), ].join(' ') + ']'; }).join(''); } diff --git a/tests/syslog.test.js b/tests/syslog.test.js index e86b71c..ee16f6f 100644 --- a/tests/syslog.test.js +++ b/tests/syslog.test.js @@ -456,7 +456,7 @@ describe('RFC5424 Class Tests', () => { structuredData: { "hi@32473": { foo: 1, - bar: 2 + bar: [2, 3] }, escape: { quoteCharacter: '"', @@ -465,7 +465,7 @@ describe('RFC5424 Class Tests', () => { } } }); - expect(result).toMatch(/^<190>1 \S+ \S+ - - - \[hi@32473 foo="1" bar="2"\]\[escape quoteCharacter="\\"" backslack="\\\\" closingBrace="\\]"\] BOMhello\n$/); + expect(result).toMatch(/^<190>1 \S+ \S+ - - - \[hi@32473 foo="1" bar="2" bar="3"\]\[escape quoteCharacter="\\"" backslack="\\\\" closingBrace="\\]"\] BOMhello\n$/); }); test('RFC5424 BuildMessage with octet-counting', () => { const rfc5424 = new SyslogPro.RFC5424({