Skip to content
Snippets Groups Projects
Commit f4de04b0 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

fix(insee api): handle apostrophe

parent 33bb7fa1
No related branches found
No related tags found
1 merge request!32Fix handle apostrophe
Pipeline #52066 passed
......@@ -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',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment