From 7dfc4897b811875a75c814910d912351f41c8a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Diamond?= <32074058+Andre-Diamond@users.noreply.github.com> Date: Tue, 28 Jan 2025 12:05:32 +0200 Subject: [PATCH] refactor: Update sanitizeObject function to replace line breaks with spaces --- netlify/functions/batchUpdateMeetingSummariesArray.js | 2 ++ netlify/functions/batchUpdateMeetingSummariesById.js | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/netlify/functions/batchUpdateMeetingSummariesArray.js b/netlify/functions/batchUpdateMeetingSummariesArray.js index 8bdb256..29985a5 100644 --- a/netlify/functions/batchUpdateMeetingSummariesArray.js +++ b/netlify/functions/batchUpdateMeetingSummariesArray.js @@ -7,10 +7,12 @@ const MAX_CONCURRENT_REQUESTS = 10; function sanitizeObject(item) { if (typeof item === 'string') { + // Replace line breaks with spaces // Only replace en dash (U+2013) or em dash (U+2014) with ASCII hyphen '-' // Replace curly single quotes ’ and ‘ with straight ASCII apostrophe ' // Replace curly double quotes ” and “ with straight ASCII quote " return item + .replace(/\r?\n/g, ' ') .replace(/[\u2013\u2014]/g, '-') .replace(/[\u2018\u2019]/g, "'") .replace(/[\u201C\u201D]/g, '"') diff --git a/netlify/functions/batchUpdateMeetingSummariesById.js b/netlify/functions/batchUpdateMeetingSummariesById.js index eed498d..83bd65f 100644 --- a/netlify/functions/batchUpdateMeetingSummariesById.js +++ b/netlify/functions/batchUpdateMeetingSummariesById.js @@ -7,14 +7,16 @@ const MAX_CONCURRENT_REQUESTS = 10; function sanitizeObject(item) { if (typeof item === 'string') { + // Replace line breaks with spaces // Only replace en dash (U+2013) or em dash (U+2014) with ASCII hyphen '-' // Replace curly single quotes ’ and ‘ with straight ASCII apostrophe ' // Replace curly double quotes ” and “ with straight ASCII quote " return item - .replace(/[\u2013\u2014]/g, '-') - .replace(/[\u2018\u2019]/g, "'") - .replace(/[\u201C\u201D]/g, '"') - .trim(); + .replace(/\r?\n/g, ' ') + .replace(/[\u2013\u2014]/g, '-') + .replace(/[\u2018\u2019]/g, "'") + .replace(/[\u201C\u201D]/g, '"') + .trim(); } if (Array.isArray(item)) {