Skip to content

Commit

Permalink
Merge pull request #437 from Inist-CNRS/fix-csv-object
Browse files Browse the repository at this point in the history
fix: 🐛 avoid crash with bad data
  • Loading branch information
touv authored Dec 20, 2024
2 parents f7f3cee + 0a7e997 commit 33ca88c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/basics/src/csv-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function CSVObject(data, feed) {
}

if (!this.columns) {
this.columns = data.map((name) => name.replace(/\./g, ''));
this.columns = Array().concat(data).map((name) => String(name).replace(/\./g, ''));

const countCols = {};
const renamedCols = {};
Expand Down
19 changes: 19 additions & 0 deletions packages/basics/test/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,25 @@ describe('test', () => {
done();
});
});
it('CSVObject Error', (done) => {
const res = [];
from([
true,
'vrai',
'ok'
])
.pipe(ezs('CSVObject'))
.pipe(ezs.catch())
.on('error', done)
.on('data', (chunk) => {
res.push(chunk);
})
.on('end', () => {
assert.equal(0, res.length);
done();
});
});


it('JSONString #0a', (done) => {
let res = '';
Expand Down

0 comments on commit 33ca88c

Please sign in to comment.