Fix atom item with multiple authors not getting converted to string
This commit is contained in:
parent
c2323ae19a
commit
4ee51e3ef5
|
@ -73,12 +73,11 @@ defmodule FeedParser.Parser.Atom do
|
||||||
end
|
end
|
||||||
|
|
||||||
author =
|
author =
|
||||||
texts('/entry/author/name/text()', entry) ||
|
(texts('/entry/author/name/text()', entry) || feed_author)
|
||||||
feed_author
|
|> case do
|
||||||
|> case do
|
nil -> nil
|
||||||
nil -> nil
|
authors -> Enum.join(authors, ", ")
|
||||||
authors -> Enum.join(authors, ", ")
|
end
|
||||||
end
|
|
||||||
|
|
||||||
content = text('/entry/content/text()', entry) || text('/entry/summary/text()', entry)
|
content = text('/entry/content/text()', entry) || text('/entry/summary/text()', entry)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
|
|
||||||
|
<title>Example Feed</title>
|
||||||
|
<link href="http://example.org/"/>
|
||||||
|
<updated>2003-12-13T18:30:02Z</updated>
|
||||||
|
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
|
||||||
|
|
||||||
|
<entry>
|
||||||
|
<title>Atom-Powered Robots Run Amok</title>
|
||||||
|
<link href="http://example.org/2003/12/13/atom03"/>
|
||||||
|
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
|
||||||
|
<updated>2003-12-13T18:30:02Z</updated>
|
||||||
|
<summary>Some text.</summary>
|
||||||
|
<author>
|
||||||
|
<name>John Doe</name>
|
||||||
|
</author>
|
||||||
|
<author>
|
||||||
|
<name>Jane Doe</name>
|
||||||
|
</author>
|
||||||
|
</entry>
|
||||||
|
|
||||||
|
</feed>
|
|
@ -48,4 +48,11 @@ defmodule FeedParser.Parser.AtomTest do
|
||||||
assert {:ok, %FeedParser.Feed{items: items}} = Atom.parse_feed(parsed_data)
|
assert {:ok, %FeedParser.Feed{items: items}} = Atom.parse_feed(parsed_data)
|
||||||
assert [%FeedParser.Item{creator: "John Doe, Jane Doe"}] = items
|
assert [%FeedParser.Item{creator: "John Doe, Jane Doe"}] = items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "parses ato item with multiple authors" do
|
||||||
|
data = File.read!("test/fixtures/atom/multi_author_item.xml")
|
||||||
|
{true, parsed_data} = Atom.accepts(data, "application/atom+xml")
|
||||||
|
assert {:ok, %FeedParser.Feed{items: items}} = Atom.parse_feed(parsed_data)
|
||||||
|
assert [%FeedParser.Item{creator: "John Doe, Jane Doe"}] = items
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue