From 2a372674a2267971b40f2733679fce94ad15ab19 Mon Sep 17 00:00:00 2001 From: Julien Voisin Date: Thu, 21 Aug 2025 04:01:59 +0200 Subject: [PATCH] refactor(icon): avoid calling `AbsoluteURL` twice for the feed icon URL The url of a feed's icon is always absolute. --- internal/reader/icon/finder.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/internal/reader/icon/finder.go b/internal/reader/icon/finder.go index 9f73d566..2ff96031 100644 --- a/internal/reader/icon/finder.go +++ b/internal/reader/icon/finder.go @@ -53,8 +53,8 @@ func (f *iconFinder) findIcon() (*model.Icon, error) { ) if f.feedIconURL != "" { - if icon, err := f.fetchFeedIcon(); err != nil { - slog.Debug("Unable to download icon from feed", + if icon, err := f.downloadIcon(f.feedIconURL); err != nil { + slog.Debug("Unable to fetch the feed's icon", slog.String("website_url", f.websiteURL), slog.String("feed_icon_url", f.feedIconURL), slog.Any("error", err), @@ -94,20 +94,6 @@ func (f *iconFinder) fetchDefaultIcon() (*model.Icon, error) { return icon, nil } -func (f *iconFinder) fetchFeedIcon() (*model.Icon, error) { - slog.Debug("Fetching feed icon", - slog.String("website_url", f.websiteURL), - slog.String("feed_icon_url", f.feedIconURL), - ) - - iconURL, err := urllib.AbsoluteURL(f.websiteURL, f.feedIconURL) - if err != nil { - return nil, fmt.Errorf(`icon: unable to convert icon URL to absolute URL: %w`, err) - } - - return f.downloadIcon(iconURL) -} - func (f *iconFinder) fetchIconsFromHTMLDocument() (*model.Icon, error) { slog.Debug("Searching icons from HTML document", slog.String("website_url", f.websiteURL),