Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ declare namespace Parser {
items: (U & Item)[];
feedUrl?: string;
description?: string;
subtitle?: string;
itunes?: {
[key: string]: any;
image?: string;
Expand Down
1 change: 1 addition & 0 deletions lib/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fields.feed = [
['dc:type', 'type'],
'title',
'description',
'subtitle',
'author',
'pubDate',
'webMaster',
Expand Down
5 changes: 5 additions & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ class Parser {
if (title._) title = title._
if (title) feed.title = title;
}
if (xmlObj.feed.subtitle) {
let subtitle = xmlObj.feed.subtitle[0] || '';
if (subtitle._) subtitle = subtitle._;
if (subtitle) feed.subtitle = subtitle;
}
if (xmlObj.feed.updated) {
feed.lastBuildDate = xmlObj.feed.updated[0];
}
Expand Down
19 changes: 19 additions & 0 deletions test/input/subtitle-atom.atom
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>urn:uuid:test-feed-subtitle</id>
<title>Test Feed with Subtitle</title>
<subtitle>This is the feed subtitle</subtitle>
<updated>2024-01-01T00:00:00Z</updated>
<link href="http://example.com/feed" rel="self" type="application/atom+xml"/>
<link href="http://example.com" rel="alternate" type="text/html"/>
<author>
<name>Test Author</name>
</author>
<entry>
<id>urn:uuid:test-entry-1</id>
<title>Test Entry</title>
<link href="http://example.com/entry1" rel="alternate" type="text/html"/>
<updated>2024-01-01T00:00:00Z</updated>
<summary>This is a test entry</summary>
</entry>
</feed>
15 changes: 15 additions & 0 deletions test/input/subtitle.rss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Test Feed with Subtitle</title>
<link>http://example.com</link>
<description>This is the feed description</description>
<subtitle>This is the feed subtitle</subtitle>
<item>
<title>Test Entry</title>
<link>http://example.com/entry1</link>
<description>This is a test entry</description>
<pubDate>Mon, 01 Jan 2024 00:00:00 GMT</pubDate>
</item>
</channel>
</rss>
1 change: 1 addition & 0 deletions test/output/feedburner.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
"link": "http://googleadsdeveloper.blogspot.com/search/label/adwords_api",
"feedUrl": "http://www.blogger.com/feeds/7815614485808579332/posts/default/-/adwords_api/-/adwords_api?start-index=26&max-results=25",
"title": "Google Ads Developer Blog",
"subtitle": "The official blog for information about the AdWords, AdSense, DoubleClick and AdMob APIs and SDKs.",
"lastBuildDate": "2016-06-27T07:36:54.007-07:00"
}
}
1 change: 1 addition & 0 deletions test/output/heise.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
"link": "http://www.heise.de/developer/",
"feedUrl": "http://www.heise.de/developer/rss/news-atom.xml",
"title": "heise developer neueste Meldungen",
"subtitle": "Informationen für Entwickler",
"lastBuildDate": "2016-02-01T17:54:50+01:00"
}
}
1 change: 1 addition & 0 deletions test/output/many-links.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
"link": "http://testing.googleblog.com/",
"feedUrl": "http://www.blogger.com/feeds/15045980/posts/default?start-index=26&max-results=25&redirect=false",
"title": "Google Testing Blog",
"subtitle": "If it ain't broke, you're not trying hard enough.",
"lastBuildDate": "2017-10-18T03:40:38.732-07:00"
}
}
19 changes: 19 additions & 0 deletions test/output/subtitle-atom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"feed": {
"items": [
{
"title": "Test Entry",
"link": "http://example.com/entry1",
"pubDate": "2024-01-01T00:00:00.000Z",
"summary": "This is a test entry",
"id": "urn:uuid:test-entry-1",
"isoDate": "2024-01-01T00:00:00.000Z"
}
],
"link": "http://example.com",
"feedUrl": "http://example.com/feed",
"title": "Test Feed with Subtitle",
"subtitle": "This is the feed subtitle",
"lastBuildDate": "2024-01-01T00:00:00Z"
}
}
18 changes: 18 additions & 0 deletions test/output/subtitle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"feed": {
"items": [
{
"title": "Test Entry",
"link": "http://example.com/entry1",
"pubDate": "Mon, 01 Jan 2024 00:00:00 GMT",
"content": "This is a test entry",
"contentSnippet": "This is a test entry",
"isoDate": "2024-01-01T00:00:00.000Z"
}
],
"title": "Test Feed with Subtitle",
"description": "This is the feed description",
"subtitle": "This is the feed subtitle",
"link": "http://example.com"
}
}
8 changes: 8 additions & 0 deletions test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,12 @@ describe('Parser', function() {
it('should parse atom:link pagination links', function (done) {
testParseForFile('pagination-links', 'rss', done);
});

it('should parse subtitle from RSS feed', function(done) {
testParseForFile('subtitle', 'rss', done);
});

it('should parse subtitle from Atom feed', function(done) {
testParseForFile('subtitle-atom', 'atom', done);
});
})