Add text/rss+xml to RSS2 MIME types

This commit is contained in:
Shadowfacts 2021-08-29 19:25:38 -04:00
parent 8c42d45873
commit b8de34c436
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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