fix problem in LDJSON parser when address object is not available

This commit is contained in:
Ondřej Synáček 2019-11-25 21:51:35 +01:00
parent 3b876631b9
commit 7234d442e3
1 changed files with 6 additions and 2 deletions

View File

@ -9,13 +9,17 @@ const parseEventData = (eventData) => {
const { location } = eventData || {} const { location } = eventData || {}
const { address } = location || {} const { address } = location || {}
const locationStr = location ? [ const locationName = location ? location.name : ''
location.name || '', const addressStr = address ? [
address.streetAddress || '', address.streetAddress || '',
address.addressLocality || '', address.addressLocality || '',
address.postalCode || '', address.postalCode || '',
address.addressCountry || '', address.addressCountry || '',
].join(' ') : '' ].join(' ') : ''
const locationStr = [
locationName,
addressStr,
].join(' ')
const cleanedLocationStr = locationStr.replace(/\r?\n|\r/g, ' ') const cleanedLocationStr = locationStr.replace(/\r?\n|\r/g, ' ')
const title = eventData.name || '' const title = eventData.name || ''
const url = eventData.url || '' const url = eventData.url || ''