rss-parser
Advanced tools
Comparing version 2.10.6 to 2.10.8
16
index.js
@@ -77,2 +77,10 @@ 'use strict'; | ||
var getLink = function(links, rel, fallbackIdx) { | ||
if (!links) return; | ||
for (var i = 0; i < links.length; ++i) { | ||
if (links[i].$.rel === rel) return links[i].$.href; | ||
} | ||
if (links[fallbackIdx]) return links[fallbackIdx].$.href; | ||
} | ||
var getContent = function(content) { | ||
@@ -96,4 +104,4 @@ if (typeof content._ === 'string') { | ||
if (feed.link) { | ||
if (feed.link[0] && feed.link[0].$.href) json.feed.link = feed.link[0].$.href; | ||
if (feed.link[1] && feed.link[1].$.href) json.feed.feedUrl = feed.link[1].$.href; | ||
json.feed.link = getLink(feed.link, 'alternate', 0); | ||
json.feed.feedUrl = getLink(feed.link, 'self', 1); | ||
} | ||
@@ -116,3 +124,5 @@ if (feed.title) { | ||
} | ||
if (entry.link && entry.link.length) item.link = entry.link[0].$.href; | ||
if (entry.link && entry.link.length) { | ||
item.link = getLink(entry.link, 'alternate', 0); | ||
} | ||
if (entry.updated && entry.updated.length) item.pubDate = new Date(entry.updated[0]).toISOString(); | ||
@@ -119,0 +129,0 @@ if (entry.author && entry.author.length) item.author = entry.author[0].name[0]; |
{ | ||
"name": "rss-parser", | ||
"version": "2.10.6", | ||
"version": "2.10.8", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -831,6 +831,6 @@ { | ||
"totalViews": "2131244", | ||
"link": "http://www.youtube.com/feeds/videos.xml?channel_id=UCBcRF18a7Qf58cCRy5xuWwQ", | ||
"feedUrl": "https://www.youtube.com/channel/UCBcRF18a7Qf58cCRy5xuWwQ", | ||
"link": "https://www.youtube.com/channel/UCBcRF18a7Qf58cCRy5xuWwQ", | ||
"feedUrl": "http://www.youtube.com/feeds/videos.xml?channel_id=UCBcRF18a7Qf58cCRy5xuWwQ", | ||
"title": "L2inc" | ||
} | ||
} |
@@ -125,6 +125,6 @@ { | ||
], | ||
"link": "http://www.heise.de/developer/rss/news-atom.xml", | ||
"feedUrl": "http://www.heise.de/developer/", | ||
"link": "http://www.heise.de/developer/", | ||
"feedUrl": "http://www.heise.de/developer/rss/news-atom.xml", | ||
"title": "heise developer neueste Meldungen" | ||
} | ||
} |
@@ -70,2 +70,3 @@ "use strict"; | ||
}); | ||
it('should parse podcasts', function(done) { | ||
@@ -75,2 +76,6 @@ testParseForFile('narro', 'rss', done); | ||
it('should parse multiple links', function(done) { | ||
testParseForFile('many-links', 'rss', done); | ||
}); | ||
it('should throw error for unrecognized', function(done) { | ||
@@ -77,0 +82,0 @@ Parser.parseFile(__dirname + '/input/unrecognized.rss', function(err, parsed) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
3638967
46
18957