Skip to content

Commit c792107

Browse files
committed
fix test issues
1 parent d6ca9c2 commit c792107

4 files changed

Lines changed: 37 additions & 12 deletions

File tree

src/rowSplit.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ describe("RowSplit.parse function", function () {
132132
noheader: true
133133
}));
134134
const res = rowSplit.parse(data);
135-
console.log(res);
136135
assert.equal(res.cells.length, 3);
137136
assert(res.closed);
138137
assert.equal(res.cells[0],'"Weight" (kg)');

src/rowSplit.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,24 @@ export class RowSplit {
7373
e = this.escapeQuote(e);
7474
row.push(e);
7575
continue;
76-
} else if (e.lastIndexOf(quote) !== 0) {
77-
if (trim) {
78-
e = trimRight(e);
76+
} else if (e.indexOf(quote) !== -1) {
77+
let count = 0;
78+
for (const c of e) {
79+
if (c === quote) {
80+
count++;
81+
}
82+
}
83+
if (count % 2 === 1) {
84+
if (trim) {
85+
e = trimRight(e);
86+
}
87+
row.push(quote + e);
88+
continue;
89+
}else{
90+
inquote = true;
91+
quoteBuff += e;
92+
continue;
7993
}
80-
row.push(quote+e);
81-
continue;
8294
}
8395
else {
8496
inquote = true;

v2/rowSplit.js

Lines changed: 19 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v2/rowSplit.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)