handle isPermalink in rss feeds

This commit is contained in:
Nazar Kanaev
2023-05-20 23:26:22 +01:00
parent 7d99edab8d
commit bc18557820
3 changed files with 39 additions and 3 deletions

View File

@@ -203,3 +203,28 @@ func TestRSSTitleHTMLTags(t *testing.T) {
}
}
}
func TestRSSIsPermalink(t *testing.T) {
feed, _ := Parse(strings.NewReader(`
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<item>
<guid isPermaLink="true">http://example.com/posts/1</guid>
</item>
</channel>
</rss>
`))
have := feed.Items
want := []Item{
{
GUID: "http://example.com/posts/1",
URL: "http://example.com/posts/1",
},
}
for i := 0; i < len(want); i++ {
if want[i] != have[i] {
t.Errorf("Failed to handle isPermalink\nwant: %#v\nhave: %#v\n", want[i], have[i])
}
}
}