danmactough/node-feedparser

atom feed where item.link is null but item['atom:link']['@']['href'] is good

pkra opened this issue · 3 comments

pkra commented

When processing this feed, the link value is null but atom:link@href is correct.

The feed validates but is missing an xml declaration.

var FeedParser = require('feedparser');
var request = require('request'); // for fetching the feed

var req = request('https://ncatlab.org/nlab/atom_with_headlines')
var feedparser = new FeedParser();

req.on('response', function (res) {
  var stream = this; // `this` is `req`, which is a stream

  if (res.statusCode !== 200) {
    this.emit('error', new Error('Bad status code'));
  }
  else {
    stream.pipe(feedparser);
  }
});
feedparser.on('readable', function () {
  // This is where the action is!
  var stream = this; // `this` is `feedparser`, which is a stream
  var item;
  while (item = stream.read()) {
    console.log(item['atom:link']['@']['href']);
    console.log(item.link);
  }
});

thanks @pkra. confirming this is a bug. looks like we're being too picky with some attribute checking.

pkra commented

Thanks for taking a look and thanks for your excellent library. If you think an outsider can tackle this, I'll try to find time (though I'm afraid I only use feedparser in a side project).