Update convert.js

This commit is contained in:
Drew Harwell 2017-05-01 12:07:58 -05:00 committed by GitHub
parent d4b1891e89
commit 2bcec3c2d1
1 changed files with 15 additions and 4 deletions

View File

@ -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;