Add text/rss+xml to RSS2 MIME types
This commit is contained in:
parent
8c42d45873
commit
b8de34c436
|
@ -10,11 +10,11 @@ defmodule FeedParser.Parser.RSS2 do
|
|||
|
||||
@impl FeedParser.Parser
|
||||
def accepts(data, content_type) do
|
||||
case content_type do
|
||||
"application/rss+xml" ->
|
||||
cond do
|
||||
content_type in ["application/rss+xml", "text/rss+xml"] ->
|
||||
{true, XML.parse(data)}
|
||||
|
||||
_ when content_type in ["text/xml", "application/xml"] ->
|
||||
content_type in ["text/xml", "application/xml"] ->
|
||||
doc = XML.parse(data)
|
||||
|
||||
if XML.xmlElement(doc, :name) == :rss do
|
||||
|
@ -23,7 +23,7 @@ defmodule FeedParser.Parser.RSS2 do
|
|||
false
|
||||
end
|
||||
|
||||
_ ->
|
||||
true ->
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,9 @@ defmodule FeedParser.Parser.RSS2Test do
|
|||
test "matches rss2 feed" do
|
||||
data = File.read!("test/fixtures/rss2/feed.xml")
|
||||
assert {true, _} = RSS2.accepts(data, "application/rss+xml")
|
||||
assert {true, _} = RSS2.accepts(data, "text/rss+xml")
|
||||
assert {true, _} = RSS2.accepts(data, "application/xml")
|
||||
assert {true, _} = RSS2.accepts(data, "text/xml")
|
||||
end
|
||||
|
||||
test "parses rss2 feed" do
|
||||
|
|
Loading…
Reference in New Issue