Try to find an HTML-type link first when parsing atom feeds (#784)

Signed-off-by: Charlotte Van Petegem <charlotte@vanpetegem.me>
Co-authored-by: Will Hunt <will@half-shot.uk>
This commit is contained in:
Charlotte Van Petegem 2023-06-28 17:35:06 +02:00 committed by GitHub
parent 3217b9eecf
commit 4351a37131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

1
changelog.d/784.bugfix Normal file
View File

@ -0,0 +1 @@
Feeds now tries to find an HTML-type link before falling back to the first link when parsing atom feeds

View File

@ -102,7 +102,12 @@ fn parse_feed_to_js_result(feed: &Feed) -> JsRssChannel {
.iter()
.map(|item| FeedItem {
title: Some(item.title().value.clone()),
link: item.links().first().map(|f| f.href.clone()),
link: item
.links()
.iter()
.find(|l| l.mime_type.as_ref().map_or(false, |t| t == "text/html"))
.or_else(|| item.links().first())
.map(|f| f.href.clone()),
id: Some(item.id.clone()),
// No equivalent
id_is_permalink: false,