Skip to content

Commit

Permalink
Fix: regex to handle line without line break
Browse files Browse the repository at this point in the history
  • Loading branch information
lvancraen committed Jun 21, 2019
1 parent 34a03ae commit ac62dfe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions helpers/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function getKeysAndRowsSlices(buffer, regexPatternObjects, tableName) {
iteration.
*/
const decoder = new StringDecoder('utf8');
const rowsSliceRegex = /(.*[\r\n]+)((.*[\r\n]*)*)/;
const rowsSliceRegex = /(.*([\r\n])*)((.*[\r\n]*)*)/;

while (position < buffer.length) {
rowsSlice = decoder.write(buffer.slice(position, Math.min(buffer.length, position + batchLength)));
Expand All @@ -80,13 +80,13 @@ function getKeysAndRowsSlices(buffer, regexPatternObjects, tableName) {
const rowsSliceIndex = position / batchLength;

if (!keys) {
const [, firstRowSlice, remainingRowsSlice] = rowsSlice.match(rowsSliceRegex);
const [, firstRowSlice,, remainingRowsSlice] = rowsSlice.match(rowsSliceRegex);
keys = firstRowSlice;
rowsSlice = remainingRowsSlice;
}

if (merge) {
const [, firstRowSlice, remainingRowsSlice] = rowsSlice.match(rowsSliceRegex);
const [, firstRowSlice,, remainingRowsSlice] = rowsSlice.match(rowsSliceRegex);
rowsSlices[rowsSliceIndex - 1] += firstRowSlice;
rowsSlice = remainingRowsSlice;
}
Expand Down

0 comments on commit ac62dfe

Please sign in to comment.