fix(csv-export): escape special characters (#268)

This commit is contained in:
Carlos Valente
2022-12-11 19:17:41 +01:00
committed by GitHub
parent dfef6d4e79
commit 2021d9394d
4 changed files with 14 additions and 9 deletions
+4 -5
View File
@@ -1,3 +1,5 @@
import { stringify } from 'csv-stringify/browser/esm/sync';
/**
* @description parses a field for export
* @param {string} field
@@ -99,9 +101,6 @@ export const makeTable = (headerData, tableData, userFields) => {
*/
export const makeCSV = (arrayOfArrays) => {
let csvData = 'data:text/csv;charset=utf-8,';
arrayOfArrays.forEach((rowArray) => {
const row = rowArray.join(',');
csvData += `${row}\n`;
});
return csvData;
const stringifiedData = stringify(arrayOfArrays);
return csvData + stringifiedData;
};