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
|
@impl FeedParser.Parser
|
||||||
def accepts(data, content_type) do
|
def accepts(data, content_type) do
|
||||||
case content_type do
|
cond do
|
||||||
"application/rss+xml" ->
|
content_type in ["application/rss+xml", "text/rss+xml"] ->
|
||||||
{true, XML.parse(data)}
|
{true, XML.parse(data)}
|
||||||
|
|
||||||
_ when content_type in ["text/xml", "application/xml"] ->
|
content_type in ["text/xml", "application/xml"] ->
|
||||||
doc = XML.parse(data)
|
doc = XML.parse(data)
|
||||||
|
|
||||||
if XML.xmlElement(doc, :name) == :rss do
|
if XML.xmlElement(doc, :name) == :rss do
|
||||||
|
@ -23,7 +23,7 @@ defmodule FeedParser.Parser.RSS2 do
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
_ ->
|
true ->
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,9 @@ defmodule FeedParser.Parser.RSS2Test do
|
||||||
test "matches rss2 feed" do
|
test "matches rss2 feed" do
|
||||||
data = File.read!("test/fixtures/rss2/feed.xml")
|
data = File.read!("test/fixtures/rss2/feed.xml")
|
||||||
assert {true, _} = RSS2.accepts(data, "application/rss+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, "application/xml")
|
||||||
|
assert {true, _} = RSS2.accepts(data, "text/xml")
|
||||||
end
|
end
|
||||||
|
|
||||||
test "parses rss2 feed" do
|
test "parses rss2 feed" do
|
||||||
|
|
Loading…
Reference in New Issue