Merge pull request #274 from mishako/rss-2-by-default

Use RSS2 parser as fallback when no version is set
This commit is contained in:
Patrick Gotthard 2016-03-01 21:25:42 +01:00
commit a058deb267
2 changed files with 12 additions and 1 deletions

View file

@ -51,7 +51,8 @@ public class RSS20Parser extends RSS094Parser {
@Override
public boolean isMyType(final Document document) {
return rootElementMatches(document) && versionMatches(document);
return rootElementMatches(document)
&& (versionMatches(document) || versionAbsent(document));
}
private boolean rootElementMatches(final Document document) {
@ -63,4 +64,8 @@ public class RSS20Parser extends RSS094Parser {
return (version != null)
&& version.getValue().trim().startsWith(getRSSVersion());
}
private boolean versionAbsent(final Document document) {
return document.getRootElement().getAttribute("version") == null;
}
}

View file

@ -44,4 +44,10 @@ public class RSS20ParserTest {
document.setRootElement(new Element("rss").setAttribute("version", "2.0test"));
assertTrue(parser.isMyType(document));
}
@Test
public void testIsMyTypeVersionAbsent() {
document.setRootElement(new Element("rss"));
assertTrue(parser.isMyType(document));
}
}