Skip to content

Commit

Permalink
fix: accept newlines passed into table data (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr authored and gajus committed Jan 14, 2019
1 parent 3d1d8b9 commit 24516c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/validateTableData.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ export default (rows) => {
throw new Error('Table must have a consistent number of cells.');
}

// @todo Make an exception for newline characters.
// @see https://github.com/gajus/table/issues/9
for (const cell of cells) {
// eslint-disable-next-line no-control-regex
if (/[\u0001-\u001A]/.test(cell)) {
if (/[\u0001-\u0009\u000B-\u001A]/.test(cell)) {
throw new Error('Table data must not contain control characters.');
}
}
Expand Down
6 changes: 6 additions & 0 deletions test/validateTableData.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ describe('validateTableData', () => {
});
});

context('cell data contains newlines', () => {
it('does not throw', () => {
validateTableData([['ab\nc']]);
});
});

context('rows have inconsistent number of cells', () => {
it('throws an error', () => {
expect(() => {
Expand Down

0 comments on commit 24516c4

Please sign in to comment.