From 7e9bbc16c757fb25f3fdfca42c302f8f9458face Mon Sep 17 00:00:00 2001
From: Bastien DUMONT <bdumont@grandlyon.com>
Date: Tue, 28 Mar 2023 13:19:00 +0000
Subject: [PATCH] =?UTF-8?q?fix(insee):=20add=20missing=20=C3=A0=20and=20?=
 =?UTF-8?q?=C3=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 __tests__/requests/insee.spec.js | 21 +++++++++++++++++++++
 src/requests/insee.js            |  3 ++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/__tests__/requests/insee.spec.js b/__tests__/requests/insee.spec.js
index 057c0bd..f8b82a5 100644
--- a/__tests__/requests/insee.spec.js
+++ b/__tests__/requests/insee.spec.js
@@ -75,6 +75,18 @@ describe('getInseeCode', () => {
       expect(await getInseeCode('69530', 'Brignais')).toEqual('69027')
     })
 
+    it('should return insee code for: Saint-Christophe-à-Berry', async () => {
+      expect(await getInseeCode('02290', 'Saint-Christophe-à-Berry')).toEqual(
+        '02673'
+      )
+    })
+
+    it('should return insee code for: Saint-Christophe-a-Berry', async () => {
+      expect(await getInseeCode('02290', 'Saint-Christophe-a-Berry')).toEqual(
+        '02673'
+      )
+    })
+
     describe('should handle communes with "Saint" or "St"', () => {
       it("should return insee code for: Saint Romain au Mont d'Or", async () => {
         expect(await getInseeCode(69270, "Saint Romain au Mont d'Or")).toEqual(
@@ -163,5 +175,14 @@ describe('getInseeCode', () => {
         )
       })
     })
+
+    describe('should return correct insee code for Bréançon', () => {
+      it('should return insee code for: Bréançon', async () => {
+        expect(await getInseeCode(95640, 'Bréançon')).toEqual('95102')
+      })
+      it('should return insee code for: Breancon', async () => {
+        expect(await getInseeCode(95640, 'Breancon')).toEqual('95102')
+      })
+    })
   })
 })
diff --git a/src/requests/insee.js b/src/requests/insee.js
index 04f4f99..10cb96e 100644
--- a/src/requests/insee.js
+++ b/src/requests/insee.js
@@ -52,7 +52,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()
 }
 
@@ -73,6 +73,7 @@ const REPLACE_CHARS = {
   "'": '',
   '’': '',
   é: 'e',
+  à: 'a',
   è: 'e',
   ç: 'c',
 }
-- 
GitLab