From f4de04b00535400030033a0389aace464c3c21d6 Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Fri, 3 Feb 2023 09:37:04 +0100 Subject: [PATCH] fix(insee api): handle apostrophe --- src/requests/insee.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/requests/insee.js b/src/requests/insee.js index a0a3dda..4ebf988 100644 --- a/src/requests/insee.js +++ b/src/requests/insee.js @@ -22,6 +22,7 @@ async function getInseeCode(postalCode, city) { if (!city) throw new Error('No city') const parsedCity = sanitizeCity(city) + console.log(parsedCity) const filteredResponse = response.data.filter( town => sanitizeCity(town.nomCommune) === parsedCity @@ -46,7 +47,7 @@ function sanitizeCity(city) { return city .toLowerCase() .replace(/\bst\b/i, 'saint') - .replace(/[âêîôûäëïü-\sʼ'éèç]/g, match => REPLACE_CHARS[match]) + .replace(/[âêîôûäëïü-\sʼ'’éèç]/g, match => REPLACE_CHARS[match]) .trim() } @@ -65,6 +66,7 @@ const REPLACE_CHARS = { ' ': '', ʼ: '', "'": '', + '’': '', é: 'e', è: 'e', ç: 'c', -- GitLab