toCSV comma fix
This commit is contained in:
parent
f9fc4fb7ff
commit
a03567eba3
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.23.18",
|
||||
"version": "0.23.19",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
@ -81,7 +81,7 @@ export function toCsv(target: any, flatten=true) {
|
||||
const value = dotNotation<any>(row, h);
|
||||
if(value == null) return '';
|
||||
if(typeof value == 'object') return `"${JSONSanitize(value).replaceAll('"', '""')}"`;
|
||||
if(typeof value == 'string' && /[\n"]/g.test(value)) return `"${value.replaceAll('"', '""')}"`;
|
||||
if(typeof value == 'string' && /[\n",]/g.test(value)) return `"${value.replaceAll('"', '""')}"`;
|
||||
return value;
|
||||
}).join(','))
|
||||
].join('\n');
|
||||
|
Loading…
x
Reference in New Issue
Block a user