From c71b4185a21de4495982eb4282bac10224849671 Mon Sep 17 00:00:00 2001
From: build-token <build-token>
Date: Mon, 6 Mar 2023 15:14:59 +0000
Subject: [PATCH] publish: Merge branch '17-partial-city' into 'main'

generated from commit 9cb0ae7973325d652e735a43479d9549cfed9d5b
---
 index.js | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/index.js b/index.js
index 2f3994e..1faf750 100644
--- a/index.js
+++ b/index.js
@@ -247508,12 +247508,17 @@ 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
+      const filteredResponse = response.data.filter(commune =>
+        sanitizeCity(commune.nomCommune).includes(parsedCity)
       )
 
+      if (filteredResponse.length > 1) {
+        throw new Error(
+          'Input city is not precise enough, more than one city was found'
+        )
+      }
+
       return filteredResponse[0].codeCommune
     }
   } catch (error) {
-- 
GitLab