8000 [pull] main from miniflux:main by pull[bot] · Pull Request #337 · suhaoGe/miniflux · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/reader/atom/atom_10_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down
28 changes: 28 additions & 0 deletions internal/reader/atom/atom_10_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1837,3 +1837,31 @@ func TestParseFeedWithIconURL(t *testing.T) {
t.Errorf("Incorrect icon URL, got: %s", feed.IconURL)
}
}

func TestParseEntryWithIDAsURL(t *testing.T) {
data := `<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example Feed</title>
<link href="http://example.org/"/>
<link href="http://example.org/atom" rel="self"/>
<entry>
<id>http://www.example.org/entries/1</id>
</entry>
<entry>
<id>mailto:john.doe@example.org</id>
</entry>
</feed>`

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)
}
}
Loading
0