Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding logic to pick out the first rel='alternate' link element if there is more than one link element in an ATOM feed. #38

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/htmlparser.js
Expand Up @@ -537,7 +537,16 @@ inherits(RssHandler, DefaultHandler);
entry.title = DomUtils.getElementsByTagName("title", item.children, false)[0].children[0].data;
} catch (ex) { }
try {
entry.link = DomUtils.getElementsByTagName("link", item.children, false)[0].attribs.href;
var linksArray = DomUtils.getElementsByTagName("link", item.children, false);
var entryLink = linksArray[0].attribs.href;
for (var i = 0; i < linksArray.length; i++) {
var linkRel = linksArray[i].attribs.rel.toLowerCase();
if (linkRel === 'alternate') {
entryLink = linksArray[i].attribs.href;
break;
}
}
entry.link = entryLink;
} catch (ex) { }
try {
entry.description = DomUtils.getElementsByTagName("summary", item.children, false)[0].children[0].data;
Expand Down