diff --git a/app/helpers/crawlers/olxClawler.js b/app/helpers/crawlers/olxClawler.js index dc4f990..d7007b7 100644 --- a/app/helpers/crawlers/olxClawler.js +++ b/app/helpers/crawlers/olxClawler.js @@ -383,9 +383,10 @@ class Indexer { const parsedPrice = parsePrice(price); - const locationArray = location.split(","); - const region = locationArray[0]; - const municipality = locationArray[1]; + const locationArray = + location && location.length > 0 ? location.split(",") : []; + const region = locationArray.length > 0 ? locationArray[0] : ""; + const municipality = locationArray.length > 1 ? locationArray[1] : ""; const data = { realEstateType: this.getCategoryId(realEstateType),