From 50f0bcd3c73d1268494cfa88fb8e4a0106960bc1 Mon Sep 17 00:00:00 2001 From: mirsal Date: Mon, 25 Nov 2024 04:03:19 +0000 Subject: [PATCH] feedreader: Handle entries with no link attribute --- src/feedreader.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/feedreader.rs b/src/feedreader.rs index bfd0666..a07837d 100644 --- a/src/feedreader.rs +++ b/src/feedreader.rs @@ -56,7 +56,7 @@ pub async fn fetch_and_parse_feed(uri: &str) -> Result> { let http_client = reqwest::Client::builder().default_headers(headers).build()?; let response = http_client.get(uri).send().await?.text().await?; - info!("Got response, parsing feed"); + info!("Got response, parsing feed from {}", uri); let feed = parser::parse(response.as_bytes())?; let feed_title = match feed.title.clone() { @@ -82,7 +82,11 @@ pub fn format_entry(feed: Feed, entry: model::Entry) -> Result t.content, None => String::from("Untitled") }, - link: entry.links[0].href.clone(), + link: if entry.links.len() > 0 { + entry.links[0].href.clone() + } else { + String::from("#") + }, ts: match entry.updated { Some(d) => d, None => entry.published.unwrap_or(Utc::now())