File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
src/Frontend/src/components/failedmessages Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -129,15 +129,23 @@ async function retrySelected() {
129
129
selectedMessages .forEach ((m ) => (m .retryInProgress = true ));
130
130
}
131
131
132
- // TODO: this function doesn't work correctly, since any commas in the exception trace breaks the CSV.
133
132
// Not attempting to use explicit types correctly since this will need to change eventually anyway
134
133
function exportSelected() {
135
134
// eslint-disable-next-line @typescript-eslint/no-explicit-any
136
135
function toCSV(array : any []) {
136
+ const delimiter = " ," ;
137
137
const keys = Object .keys (array [0 ]);
138
- let result = keys .join (" \t " ) + " \n " ;
138
+ let result = keys .join (delimiter ) + " \n " ;
139
139
array .forEach ((obj ) => {
140
- result += keys .map ((k ) => obj [k ]).join (" ," ) + " \n " ;
140
+ result +=
141
+ keys
142
+ .map ((k ) => {
143
+ let v = String (obj [k ]);
144
+ v = v .replaceAll (' "' , ' ""' ); // Escape all double quotes
145
+ if (v .search (/ ([",\n ] )/ g ) >= 0 ) v = ` "${v }" ` ; // Quote all values to deal with CR characters
146
+ return v ;
147
+ })
148
+ .join (delimiter ) + " \n " ;
141
149
});
142
150
143
151
return result ;
You can’t perform that action at this time.
0 commit comments