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

fix(insee): cleaner regexp

parent 610626ba
No related branches found
No related tags found
No related merge requests found
Pipeline #51123 passed
......@@ -76,6 +76,15 @@ describe('getInseeCode', () => {
it('should return insee code for: Puget-Rostang', async () => {
expect(await getInseeCode('06260', 'Puget-Rostang')).toEqual('06098')
})
it('should return insee code for: Rostrenen', async () => {
expect(await getInseeCode(22110, 'Rostrenen')).toEqual('22266')
})
it('should return insee code for: Kergrist Moëlou', async () => {
expect(await getInseeCode(22110, 'Kergrist Moëlou')).toEqual('22087')
})
it('should return insee code for: castets', async () => {
expect(await getInseeCode(40260, 'castets')).toEqual('40075')
})
it('should return insee code for: St léger', async () => {
expect(await getInseeCode('06260', 'St léger')).toEqual('06124')
})
......
......@@ -45,7 +45,7 @@ async function getInseeCode(postalCode, city) {
function sanitizeCity(city) {
return city
.toLowerCase()
.replace(/st/g, 'saint')
.replace(/\bst\b/i, 'saint')
.replace(/[âêîôûäëïü-\sʼ'éèç]/g, match => REPLACE_CHARS[match])
.trim()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment