MCPcopy Create free account
hub / github.com/adobe/react-spectrum / escapeCSV

Function escapeCSV

scripts/getCommitsForTesting.mjs:286–301  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

284}
285
286function escapeCSV(value) {
287 if (!value) {
288 return '';
289 }
290
291 // Normalize newlines for CSV compatibility
292 let stringValue = String(value).replace(/\r\n/g, '\n').replace(/\r/g, '\n');
293
294 // Prevent formula injection when opened in Excel/Google Sheets
295 if (/^[=+\-@\t\r]/.test(stringValue)) {
296 stringValue = `'${stringValue}`;
297 }
298
299 // Escape any internal double quotes and wrap in quotes so commas/newlines don't break the cell
300 return `"${stringValue.replace(/"/g, '""')}"`;
301}
302
303function removePRNumber(title) {
304 return title.replace(/\s*\(#\d+\)\s*$/, '');

Callers 1

formatRowsFunction · 0.85

Calls 1

StringFunction · 0.85

Tested by

no test coverage detected