From: Ardis Lu Date: Wed, 9 Jul 2025 05:42:01 +0000 (-0700) Subject: Fix bug where extra normalization headers were not dropped X-Git-Tag: v0.1.3~10 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=5a88c912cfef618bda66adad5b5c797c7269d8a2;p=csvio Fix bug where extra normalization headers were not dropped This bug was not caught due to a separate bug in the test logic, which is also fixed in this commit. --- diff --git a/src/normalization.js b/src/normalization.js index 6228832..8ddbfbf 100644 --- a/src/normalization.js +++ b/src/normalization.js @@ -154,7 +154,7 @@ export class CSVNormalizer extends TransformStream { } i++; } - this.#columns.filter(c => c.index !== null); // Drop columns provided in the headers input but not in the CSV + this.#columns = this.#columns.filter(c => c.index !== null); // Drop columns provided in the headers input but not in the CSV this.#firstChunk = false; return; } diff --git a/test/utils.js b/test/utils.js index 45f2531..a56f739 100644 --- a/test/utils.js +++ b/test/utils.js @@ -20,6 +20,7 @@ export function csvStreamEqualWritable(csv) { return new WritableStream({ write(chunk) { const row = JSON.parse(chunk); + deepStrictEqual(row.length, csv[i].length); for (let j = 0; j < csv[i].length; j++) { deepStrictEqual(row[j], csv[i][j]); }