diff --git a/lib/parseCsv.js b/lib/parseCsv.js index f763114..75e5671 100644 --- a/lib/parseCsv.js +++ b/lib/parseCsv.js @@ -8,7 +8,15 @@ function parseJoins (joins) { } function parseFolio (folio) { - return folio ? folio.split(poundSeparator) : [] + return folio + ? folio.split(poundSeparator).map(entry => { + const match = /^(?:(?.*) )(?[^ ]+)$/.exec(entry) + return { + name: match.groups.name || '', + number: match.groups.number + } + }) + : [] } function parseScript (script) { diff --git a/spec/parseCsv.spec.js b/spec/parseCsv.spec.js index 37de7c3..67dff35 100644 --- a/spec/parseCsv.spec.js +++ b/spec/parseCsv.spec.js @@ -37,7 +37,15 @@ describe('parseCsv', () => { }) it('parses ₤ folio', () => { - expectCsv({folio: 'folio1 ₤ folio2'}).toParseTo({folio: ['folio1', 'folio2']}) + expectCsv({folio: 'ABC folio1 ₤ folio2'}).toParseTo({folio: [ + { + name: 'ABC', + number: 'folio1' + }, { + name: '', + number: 'folio2' + } + ]}) }) it('parses record', () => {