diff --git a/internal/reader/atom/atom_10_adapter.go b/internal/reader/atom/atom_10_adapter.go index 9d27a2a5..f1528227 100644 --- a/internal/reader/atom/atom_10_adapter.go +++ b/internal/reader/atom/atom_10_adapter.go @@ -81,6 +81,16 @@ func (a *atom10Adapter) populateEntries(siteURL string) model.Entries { } } + // If the entry has no links, attempt to use its ID as a URL + // and if that fails, use the site URL. + if entry.URL == "" { + if urllib.IsAbsoluteURL(atomEntry.ID) { + entry.URL = atomEntry.ID + } else { + entry.URL = siteURL + } + } + // Populate the entry content. entry.Content = atomEntry.Content.body() if entry.Content == "" { diff --git a/internal/reader/atom/atom_10_test.go b/internal/reader/atom/atom_10_test.go index d7382606..310f1d19 100644 --- a/internal/reader/atom/atom_10_test.go +++ b/internal/reader/atom/atom_10_test.go @@ -1837,3 +1837,31 @@ func TestParseFeedWithIconURL(t *testing.T) { t.Errorf("Incorrect icon URL, got: %s", feed.IconURL) } } + +func TestParseEntryWithIDAsURL(t *testing.T) { + data := ` + + Example Feed + + + + http://www.example.org/entries/1 + + + mailto:john.doe@example.org + + ` + + feed, err := Parse("https://example.org/", bytes.NewReader([]byte(data)), "10") + if err != nil { + t.Fatal(err) + } + + if feed.Entries[0].URL != "http://www.example.org/entries/1" { + t.Errorf("Incorrect entry URL, got: %s", feed.Entries[0].URL) + } + + if feed.Entries[1].URL != "http://example.org/" { + t.Errorf("Incorrect entry URL, got: %s", feed.Entries[1].URL) + } +}