From 23e8972acdaf9668fe19404163bc52ce4e9e2c97 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 11:46:46 +0200 Subject: [PATCH] refactor: Enhance sanitizeObject function to replace curly quotes with ASCII equivalents --- netlify/functions/batchUpdateMeetingSummariesArray.js | 8 +++++++- netlify/functions/batchUpdateMeetingSummariesById.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/netlify/functions/batchUpdateMeetingSummariesArray.js b/netlify/functions/batchUpdateMeetingSummariesArray.js index 8fb9479..8bdb256 100644 --- a/netlify/functions/batchUpdateMeetingSummariesArray.js +++ b/netlify/functions/batchUpdateMeetingSummariesArray.js @@ -8,7 +8,13 @@ const MAX_CONCURRENT_REQUESTS = 10; function sanitizeObject(item) { if (typeof item === 'string') { // Only replace en dash (U+2013) or em dash (U+2014) with ASCII hyphen '-' - return item.replace(/[\u2013\u2014]/g, '-'); + // 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(); } if (Array.isArray(item)) { diff --git a/netlify/functions/batchUpdateMeetingSummariesById.js b/netlify/functions/batchUpdateMeetingSummariesById.js index 40330a5..eed498d 100644 --- a/netlify/functions/batchUpdateMeetingSummariesById.js +++ b/netlify/functions/batchUpdateMeetingSummariesById.js @@ -8,7 +8,13 @@ const MAX_CONCURRENT_REQUESTS = 10; function sanitizeObject(item) { if (typeof item === 'string') { // Only replace en dash (U+2013) or em dash (U+2014) with ASCII hyphen '-' - return item.replace(/[\u2013\u2014]/g, '-'); + // 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(); } if (Array.isArray(item)) {