Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csv-stringify: quoted_match is ignored for empty strings #344

Closed
MindaugasButkus opened this issue Jun 16, 2022 · 0 comments
Closed

csv-stringify: quoted_match is ignored for empty strings #344

MindaugasButkus opened this issue Jun 16, 2022 · 0 comments

Comments

@MindaugasButkus
Copy link
Contributor

MindaugasButkus commented Jun 16, 2022

Describe the bug

There is no way to quote empty strings without also quoting null and undefined values. I expect that empty string will be quoted and null / undefined values will not be quoted when options quoted_match: /^&/ and quoted_empty: false are provided. quoted_empty: true will quote empty strings, but it will also quote null and undefined values.

Node version: 16.13.2
csv-stringify version: 6.1.2

To Reproduce

import { stringify } from "csv-stringify";

stringify([
  ["a", null, undefined, "", "b"],
], {
  quoted_empty: false,
  quoted_match: /^$/,
}, (_, csv) => {
  console.log(csv);
});

Output: a,,,,b
Expected output: a,,,"",b

MindaugasButkus added a commit to MindaugasButkus/node-csv that referenced this issue Jun 16, 2022
wdavidw pushed a commit that referenced this issue Jun 16, 2022
…y strings (#345)

* fix(csv-stringify): quote_match with empty string pattern quotes empty strings (#344)

* chore: yarn build on root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant