From 7234d442e381eff6fdd9058df83e78b6f664f28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Syn=C3=A1=C4=8Dek?= Date: Mon, 25 Nov 2019 21:51:35 +0100 Subject: [PATCH] fix problem in LDJSON parser when address object is not available --- lib/services/ldjson-parser.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/services/ldjson-parser.js b/lib/services/ldjson-parser.js index 1c5a0a5..b7c188c 100644 --- a/lib/services/ldjson-parser.js +++ b/lib/services/ldjson-parser.js @@ -9,13 +9,17 @@ const parseEventData = (eventData) => { const { location } = eventData || {} const { address } = location || {} - const locationStr = location ? [ - location.name || '', + const locationName = location ? location.name : '' + const addressStr = address ? [ address.streetAddress || '', address.addressLocality || '', address.postalCode || '', address.addressCountry || '', ].join(' ') : '' + const locationStr = [ + locationName, + addressStr, + ].join(' ') const cleanedLocationStr = locationStr.replace(/\r?\n|\r/g, ' ') const title = eventData.name || '' const url = eventData.url || ''