From 2bcec3c2d1609ce2f7b419ffd5bf20efebba6045 Mon Sep 17 00:00:00 2001 From: Drew Harwell Date: Mon, 1 May 2017 12:07:58 -0500 Subject: [PATCH] Update convert.js --- lib/convert.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/convert.js b/lib/convert.js index bd52236..9855617 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -77,14 +77,25 @@ function buildUp(jsonObj,opts){ item.enclosures = []; if (item["activity:object"] && item["activity:object"].link){ - item["activity:object"].link.forEach(function(link){ + + + if (Array.isArrray(item["activity:object"].link) ){ + item["activity:object"].link.forEach(parseLink); + }else if (typeof item["activity:object"].link == 'object'){ + parseLink(item["activity:object"].link); + }else{ + console.log('cannot parse links, is type ' +typeof item["activity:object"].link); + } + + function parseLink(link){ if (!link['@']){return;} // avoid keyerror var rel = link['@'].rel; var href = link['@'].href; if (rel == 'enclosure'){ - item.enclosures.push(href); + item.enclosures.push(href); } - }); + } + } // get author info @@ -102,7 +113,7 @@ function buildUp(jsonObj,opts){ item.author.displayName = getH(_author,'poco:displayname'); var authorLinks = _author.link || []; - authorLinks.forEach(function(link){ + authorLinks.forEach(function(link){// todo: guard against authorLinks not being an array if (!link['@']){return;} // avoid keyerror var rel = link['@'].rel; var href = link['@'].href;