diff --git a/reader/atom/atom_10_test.go b/reader/atom/atom_10_test.go index 498bfadb..c6a50ef0 100644 --- a/reader/atom/atom_10_test.go +++ b/reader/atom/atom_10_test.go @@ -279,6 +279,84 @@ func TestParseEntryWithRelativeURL(t *testing.T) { } } +func TestParseEntryURLWithTextHTMLType(t *testing.T) { + data := ` + + Example Feed + + + + Test + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + 2003-12-13T18:30:02Z + Some text. + + + ` + + feed, err := Parse("https://example.net/", bytes.NewBufferString(data)) + if err != nil { + t.Fatal(err) + } + + if feed.Entries[0].URL != "http://example.org/something.html" { + t.Errorf("Incorrect entry URL, got: %s", feed.Entries[0].URL) + } +} + +func TestParseEntryURLWithNoRelAndNoType(t *testing.T) { + data := ` + + Example Feed + + + + Test + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + 2003-12-13T18:30:02Z + Some text. + + + ` + + feed, err := Parse("https://example.net/", bytes.NewBufferString(data)) + if err != nil { + t.Fatal(err) + } + + if feed.Entries[0].URL != "http://example.org/something.html" { + t.Errorf("Incorrect entry URL, got: %s", feed.Entries[0].URL) + } +} + +func TestParseEntryURLWithAlternateRel(t *testing.T) { + data := ` + + Example Feed + + + + Test + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + 2003-12-13T18:30:02Z + Some text. + + + ` + + feed, err := Parse("https://example.net/", bytes.NewBufferString(data)) + if err != nil { + t.Fatal(err) + } + + if feed.Entries[0].URL != "http://example.org/something.html" { + t.Errorf("Incorrect entry URL, got: %s", feed.Entries[0].URL) + } +} + func TestParseEntryTitleWithWhitespaces(t *testing.T) { data := ` diff --git a/reader/atom/atom_common.go b/reader/atom/atom_common.go index f6ead67f..4a01fa94 100644 --- a/reader/atom/atom_common.go +++ b/reader/atom/atom_common.go @@ -51,7 +51,7 @@ func (a atomLinks) originalLink() string { return strings.TrimSpace(link.URL) } - if link.Rel == "" && link.Type == "" { + if link.Rel == "" && (link.Type == "" || link.Type == "text/html") { return strings.TrimSpace(link.URL) } }