From a03567eba37435e5240f3517e457d1774bd00dc6 Mon Sep 17 00:00:00 2001 From: ztimson Date: Sun, 6 Apr 2025 21:37:01 -0400 Subject: [PATCH] toCSV comma fix --- package.json | 2 +- src/csv.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cbbc486..294e23c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ztimson/utils", - "version": "0.23.18", + "version": "0.23.19", "description": "Utility library", "author": "Zak Timson", "license": "MIT", diff --git a/src/csv.ts b/src/csv.ts index ae218d3..dcc9c35 100644 --- a/src/csv.ts +++ b/src/csv.ts @@ -81,7 +81,7 @@ export function toCsv(target: any, flatten=true) { const value = dotNotation(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');