krestaino / podcast-xml-parser

🎙 Parse podcast feeds in browsers, React Native, or Node.js environments.

Home Page:https://podcast-xml-parser.kmr.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`atom:link` should have `rel="self"`

harshcut opened this issue · comments

Description

When retrieving the atom:link from an RSS feed, the current implementation fails to accurately identify the correct link for the feed URL. The expected behavior is to obtain the atom:link element with the attribute rel="self", representing the feed's own URL. However, the current implementation is not consistently achieving this.

let feedUrl = documentElement.getElementsByTagName("atom:link")[0]?.getAttribute("href") ?? "";

Current Behavior

I have this feed URL, which has multiple atom:link elements, out of which the first element is of rel="hub" which should not be considered as a feed URL. The same hub is present for multiple feeds and causes an error for unique keys in database.

<!-- https://aufgeldreise.podigee.io/feed/mp3 -->
<atom:link href="https://pubsubhubbub.appspot.com/" rel="hub"/>
<atom:link href="https://aufgeldreise.podigee.io/feed/mp3" rel="self"/>
<atom:link href="https://aufgeldreise.podigee.io/feed/mp3" rel="first"/>
<atom:link href="https://aufgeldreise.podigee.io/feed/mp3?page=1" rel="last"/>

Expected Behavior

It should only identify and retrieve the atom:link element with the attribute rel="self" to obtain the feed's URL. If any links with such attribute is not found, then it should mark it as undefined.

Closing, see more here: #9 (comment)