Skip to content

Commit 24516c4

Browse files
rix0rrrgajus
authored andcommitted
fix: accept newlines passed into table data (#89)
1 parent 3d1d8b9 commit 24516c4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/validateTableData.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ export default (rows) => {
3434
throw new Error('Table must have a consistent number of cells.');
3535
}
3636

37-
// @todo Make an exception for newline characters.
38-
// @see https://github.com/gajus/table/issues/9
3937
for (const cell of cells) {
4038
// eslint-disable-next-line no-control-regex
41-
if (/[\u0001-\u001A]/.test(cell)) {
39+
if (/[\u0001-\u0009\u000B-\u001A]/.test(cell)) {
4240
throw new Error('Table data must not contain control characters.');
4341
}
4442
}

test/validateTableData.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ describe('validateTableData', () => {
5252
});
5353
});
5454

55+
context('cell data contains newlines', () => {
56+
it('does not throw', () => {
57+
validateTableData([['ab\nc']]);
58+
});
59+
});
60+
5561
context('rows have inconsistent number of cells', () => {
5662
it('throws an error', () => {
5763
expect(() => {

0 commit comments

Comments
 (0)