mirror of
https://github.com/miniflux/v2.git
synced 2025-09-30 19:22:11 +00:00
fix(jsonfeed): fallback to external_url
when url
is missing
This commit is contained in:
parent
79b0d0b9cc
commit
ff07f02716
2 changed files with 66 additions and 4 deletions
|
@ -68,11 +68,16 @@ func (j *JSONAdapter) BuildFeed(baseURL string) *model.Feed {
|
|||
for _, item := range j.jsonFeed.Items {
|
||||
entry := model.NewEntry()
|
||||
entry.Title = strings.TrimSpace(item.Title)
|
||||
entry.URL = strings.TrimSpace(item.URL)
|
||||
|
||||
// Make sure the entry URL is absolute.
|
||||
if entryURL, err := urllib.AbsoluteURL(feed.SiteURL, entry.URL); err == nil {
|
||||
entry.URL = entryURL
|
||||
for _, itemURL := range []string{item.URL, item.ExternalURL} {
|
||||
itemURL = strings.TrimSpace(itemURL)
|
||||
if itemURL != "" {
|
||||
// Make sure the entry URL is absolute.
|
||||
if entryURL, err := urllib.AbsoluteURL(feed.SiteURL, itemURL); err == nil {
|
||||
entry.URL = entryURL
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// The entry title is optional, so we need to find a fallback.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue