-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(parse): Handle escaped escape properly #340
- Loading branch information
1 parent
a71e712
commit 78d9b16
Showing
6 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Run Examples" type="js.build_tools.npm"> | ||
<package-json value="$PROJECT_DIR$/package.json" /> | ||
<command value="run" /> | ||
<scripts> | ||
<script value="examples" /> | ||
</scripts> | ||
<node-interpreter value="project" /> | ||
<envs /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Serve Docs" type="js.build_tools.npm"> | ||
<package-json value="$PROJECT_DIR$/documentation/package.json" /> | ||
<command value="run" /> | ||
<scripts> | ||
<script value="start" /> | ||
</scripts> | ||
<node-interpreter value="project" /> | ||
<envs /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Run Tests" type="JavaScriptTestRunnerJest"> | ||
<config-file value="$PROJECT_DIR$/jest.config.js" /> | ||
<node-interpreter value="project" /> | ||
<node-options value="" /> | ||
<jest-package value="$PROJECT_DIR$/node_modules/jest" /> | ||
<working-dir value="$PROJECT_DIR$/packages/parse" /> | ||
<jest-options value="--runInBand --coverage" /> | ||
<envs /> | ||
<scope-kind value="ALL" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { EOL } from 'os'; | ||
import { parseString, RowMap, RowArray } from '../../src'; | ||
|
||
describe('Issue #340 - https://github.com/C2FO/fast-csv/issues/340', () => { | ||
const CSV_CONTENT = ['Col1', `"A '"Good'" row''"`, 'Row 2'].join(EOL); | ||
const expectedRows = [{ Col1: `A "Good" row'` }, { Col1: 'Row 2' }]; | ||
|
||
it('handle a trailing escape', (done) => { | ||
const invalid: RowArray[] = []; | ||
const rows: RowMap[] = []; | ||
parseString(CSV_CONTENT, { headers: true, escape: "'" }) | ||
.on('data-invalid', (row: RowArray) => invalid.push(row)) | ||
.on('data', (r: RowMap) => rows.push(r)) | ||
.on('error', done) | ||
.on('end', (count: number) => { | ||
expect(rows).toEqual(expectedRows); | ||
expect(invalid).toHaveLength(0); | ||
expect(count).toBe(expectedRows.length + invalid.length); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters