| 284 | } |
| 285 | |
| 286 | function 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 | |
| 303 | function removePRNumber(title) { |
| 304 | return title.replace(/\s*\(#\d+\)\s*$/, ''); |