From 697f92129c1728dce800f36e380a2eaef8c81385 Mon Sep 17 00:00:00 2001 From: Helen Root Date: Fri, 29 Sep 2023 17:22:55 +0200 Subject: [PATCH] Reparer bug quand l'URL est mal fait --- front/handlers/shared.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/front/handlers/shared.js b/front/handlers/shared.js index 6fbd41f0..2f91f05b 100644 --- a/front/handlers/shared.js +++ b/front/handlers/shared.js @@ -60,9 +60,15 @@ async function getLocationDetail (req, res) { if (commune) return { commune } } else if (req.query.communes || req.query.epcis) { const location = { communes: [], epcis: [] } - if (req.query.communes) location.communes = req.query.communes.map((c) => getCommune(c, true)) - if (req.query.epcis) location.epcis = req.query.epcis.map((c) => getEpci(c, true)) - return location + if (req.query.communes && Array.isArray(req.query.communes)) { + location.communes = req.query.communes.map((c) => getCommune(c, true)) + } + if (req.query.epcis && Array.isArray(req.query.epcis)) { + location.epcis = req.query.epcis.map((c) => getEpci(c, true)) + } + if (location.communes.length || location.epcis.length) { + return location + } } }