Add support for jsonfeed new mime-type : application/feed+json

This commit is contained in:
Shinokuni 2020-09-15 13:51:17 +02:00
parent c9c316b579
commit 592fa4603a
2 changed files with 4 additions and 1 deletions

View File

@ -10,6 +10,7 @@ object LocalRSSHelper {
private const val RSS_TEXT_CONTENT_TYPE = "text/xml" private const val RSS_TEXT_CONTENT_TYPE = "text/xml"
private const val RSS_APPLICATION_CONTENT_TYPE = "application/xml" private const val RSS_APPLICATION_CONTENT_TYPE = "application/xml"
private const val ATOM_CONTENT_TYPE = "application/atom+xml" private const val ATOM_CONTENT_TYPE = "application/atom+xml"
private const val JSONFEED_CONTENT_TYPE = "application/feed+json"
private const val JSON_CONTENT_TYPE = "application/json" private const val JSON_CONTENT_TYPE = "application/json"
private const val HTML_CONTENT_TYPE = "text/html" private const val HTML_CONTENT_TYPE = "text/html"
@ -24,7 +25,7 @@ object LocalRSSHelper {
return when (contentType) { return when (contentType) {
RSS_DEFAULT_CONTENT_TYPE -> RSSType.RSS_2 RSS_DEFAULT_CONTENT_TYPE -> RSSType.RSS_2
ATOM_CONTENT_TYPE -> RSSType.ATOM ATOM_CONTENT_TYPE -> RSSType.ATOM
JSON_CONTENT_TYPE -> RSSType.JSONFEED JSON_CONTENT_TYPE, JSONFEED_CONTENT_TYPE -> RSSType.JSONFEED
RSS_TEXT_CONTENT_TYPE, RSS_APPLICATION_CONTENT_TYPE, HTML_CONTENT_TYPE -> RSSType.UNKNOWN RSS_TEXT_CONTENT_TYPE, RSS_APPLICATION_CONTENT_TYPE, HTML_CONTENT_TYPE -> RSSType.UNKNOWN
else -> throw UnknownFormatException("Unknown content type : $contentType") else -> throw UnknownFormatException("Unknown content type : $contentType")
} }

View File

@ -15,6 +15,8 @@ class LocalRSSHelperTest {
LocalRSSHelper.RSSType.ATOM) LocalRSSHelper.RSSType.ATOM)
assertEquals(LocalRSSHelper.getRSSType("application/json"), assertEquals(LocalRSSHelper.getRSSType("application/json"),
LocalRSSHelper.RSSType.JSONFEED) LocalRSSHelper.RSSType.JSONFEED)
assertEquals(LocalRSSHelper.getRSSType("application/feed+json"),
LocalRSSHelper.RSSType.JSONFEED)
} }
@Test @Test