mirror of
https://github.com/misskey-dev/SyslogPro.git
synced 2025-04-29 02:37:18 +09:00
Merge pull request #18 from zeit/structured-data-multi-values
Allow to set multiple values for a field of structured data on RFC5424
This commit is contained in:
commit
fa3eb3ff65
8
index.ts
8
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('');
|
||||
}
|
||||
|
@ -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({
|
||||
|
Loading…
x
Reference in New Issue
Block a user