From b8de34c436855b453b1e4ced1fa3659c5a35ac95 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 29 Aug 2021 19:25:38 -0400 Subject: [PATCH] Add text/rss+xml to RSS2 MIME types --- lib/parser/rss2.ex | 8 ++++---- test/parser/rss2_test.exs | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/parser/rss2.ex b/lib/parser/rss2.ex index 482a23d..41c3358 100644 --- a/lib/parser/rss2.ex +++ b/lib/parser/rss2.ex @@ -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 diff --git a/test/parser/rss2_test.exs b/test/parser/rss2_test.exs index 5bf94c7..68b0409 100644 --- a/test/parser/rss2_test.exs +++ b/test/parser/rss2_test.exs @@ -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