1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

refactor(icon): avoid calling AbsoluteURL twice for the feed icon URL

The url of a feed's icon is always absolute.
This commit is contained in:
Julien Voisin 2025-08-21 04:01:59 +02:00 committed by GitHub
parent 9d32b23ab0
commit 2a372674a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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),