mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 23:34:10 +08:00
fix(decoder): use default delimiter for parsing array headers
This commit is contained in:
@@ -267,7 +267,7 @@ function decodeListItem(
|
||||
|
||||
// Check for array header after hyphen
|
||||
if (isArrayHeaderAfterHyphen(afterHyphen)) {
|
||||
const arrayHeader = parseArrayHeaderLine(afterHyphen, activeDelimiter)
|
||||
const arrayHeader = parseArrayHeaderLine(afterHyphen, DEFAULT_DELIMITER)
|
||||
if (arrayHeader) {
|
||||
return decodeArrayFromHeader(arrayHeader.header, arrayHeader.inlineValues, cursor, baseDepth, options)
|
||||
}
|
||||
|
||||
@@ -366,6 +366,14 @@ describe('delimiter options', () => {
|
||||
expect(decode(toon)).toEqual({ pairs: [['a', 'b'], ['c', 'd']] })
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ parent: '[1\t]', nested: '[3]', values: 'a,b,c' },
|
||||
{ parent: '[1|]', nested: '[3]', values: 'a,b,c' },
|
||||
])('nested arrays inside list items default to comma delimiter', ({ parent, nested, values }) => {
|
||||
const toon = `items${parent}:\n - tags${nested}: ${values}`
|
||||
expect(decode(toon)).toEqual({ items: [{ tags: ['a', 'b', 'c'] }] })
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ header: '[3\t]', joined: 'x\ty\tz' },
|
||||
{ header: '[3|]', joined: 'x|y|z' },
|
||||
|
||||
Reference in New Issue
Block a user