diff --git a/importGasStations.js b/importGasStations.js index 3f1e752..4989e3a 100644 --- a/importGasStations.js +++ b/importGasStations.js @@ -141,10 +141,14 @@ const getStationName = (start, callback) => { } else { const html = htmlparser(body); const name = html - .querySelector("strong")? - .toString()? - .replace(/[<>/]/g, "")? - .replace(/strong/g, "") || null; + .querySelector("strong"); + + if ( name ) { + name = name + .toString()? + .replace(/[<>/]/g, "")? + .replace(/strong/g, "") || null; + } if (name) { item.name = name; @@ -209,9 +213,9 @@ fs.readFile("public/gas-stations.xml", function(err, data) { }, prices: extractPrice(currentStation), services: - currentStation.services && currentStation.services.service - ? currentStation.services.service - : [], + currentStation.services && currentStation.services.service + ? currentStation.services.service + : [], postCode: currentStation.cp.toString(), address: currentStation.adresse, city: currentStation.ville