Skip to content

Commit d0c612c

Browse files
authored
Merge pull request danmactough#246 from Alex7Kom/master
Prioritize alternate links for item.link
2 parents 48e44a9 + 36f5135 commit d0c612c

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

lib/feedparser/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ FeedParser.prototype.handleItem = function handleItem (node, type, options){
790790
if (link['@']['href']) { // Atom
791791
if (_.get(link['@'], 'rel')) {
792792
if (link['@']['rel'] == 'canonical') item.origlink = link['@']['href'];
793-
if (link['@']['rel'] == 'alternate' && !item.link) item.link = link['@']['href'];
793+
if (link['@']['rel'] == 'alternate') item.link = link['@']['href'];
794794
if (link['@']['rel'] == 'self' && !item.link) item.link = link['@']['href'];
795795
if (link['@']['rel'] == 'replies') item.comments = link['@']['href'];
796796
if (link['@']['rel'] == 'enclosure') {
@@ -813,7 +813,7 @@ FeedParser.prototype.handleItem = function handleItem (node, type, options){
813813
if (el['@']['href']) { // Atom
814814
if (_.get(el['@'], 'rel')) {
815815
if (el['@']['rel'] == 'canonical') item.origlink = el['@']['href'];
816-
if (el['@']['rel'] == 'alternate' && !item.link) item.link = el['@']['href'];
816+
if (el['@']['rel'] == 'alternate') item.link = el['@']['href'];
817817
if (el['@']['rel'] == 'self' && !item.link) item.link = el['@']['href'];
818818
if (el['@']['rel'] == 'replies') item.comments = el['@']['href'];
819819
if (el['@']['rel'] == 'enclosure') {

test/feeds/non-text-alternate-links.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<generator uri="http://golem.ph.utexas.edu/instiki/show/HomePage" version="0.19.7(MML+)">Instiki</generator>
99
<entry>
1010
<title type="html">(0,1)-category</title>
11+
<link rel="self" type="application/xhtml+xml" href="https://ncatlab.org/nlab/show/self_link/"/>
1112
<link rel="alternate" type="application/xhtml+xml" href="https://ncatlab.org/nlab/show/%280%2C1%29-category"/>
1213
<updated>2017-09-21T16:03:01Z</updated>
1314
<published>2009-09-08T23:20:59Z</published>

0 commit comments

Comments
 (0)