Skip to content

Commit

Permalink
Fix infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jdesboeufs committed May 2, 2019
1 parent 545fce1 commit 3bc708f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion full.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ function findCodePostal(codeCommune, idVoie, numero, repetition) {
}

// Si on ne trouve toujours pas on essaye sur la commune parente
return findCodePostal(codeCommune)
if (idVoieMatch !== buildIdVoie(codeCommune, 'XXXX')) {
return findCodePostal(codeCommune)
}
}

module.exports = {findCodePostal}
4 changes: 4 additions & 0 deletions test/full.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ test('Saint-Maur-des-Fossés 5', t => {
test('Mont-Bonvillers', t => {
t.is(findCodePostal('54084').codePostal, '54111')
})

test('Commune inconnue', t => {
t.is(findCodePostal('54999'), undefined)
})

0 comments on commit 3bc708f

Please sign in to comment.