Socket
Socket
Sign inDemoInstall

rss-parser

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rss-parser - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

test/input/narro.rss

69

index.js

@@ -10,3 +10,18 @@ var Entities = require("entities");

var TOP_FIELDS = ['title', 'description', 'author', 'link'];
var TOP_FIELDS = [
'title',
'description',
'author',
'pubDate',
'webMaster',
'managingEditor',
'generator',
'link'
];
var PODCAST_TOP_FIELDS = [
'author',
'subtitle',
'summary',
'explicit'
];
var ITEM_FIELDS = [

@@ -18,4 +33,13 @@ 'title',

'content:encoded',
]
'enclosure'
];
var PODCAST_ITEM_FIELDS = [
'author',
'subtitle',
'summary',
'explicit',
'duration'
];
var stripHtml = function(str) {

@@ -82,3 +106,3 @@ return str.replace(/<(?:.|\n)*?>/gm, '');

var channel = xmlObj.rss.channel[0];
if (channel['atom:link']) json.feed.feedUrl = channel['atom:link'][0].href;
if (channel['atom:link']) json.feed.feedUrl = channel['atom:link'][0].$.href;
TOP_FIELDS.forEach(function(f) {

@@ -93,2 +117,5 @@ if (channel[f]) json.feed[f] = channel[f][0];

})
if (item.enclosure) {
entry.enclosure = item.enclosure[0].$;
}
if (item.description) {

@@ -105,5 +132,41 @@ entry.content = getContent(item.description[0]);

})
if (xmlObj.rss.$['xmlns:itunes']) {
decorateItunes(json, channel);
}
callback(null, json);
}
/**
* Add iTunes specific fields from XML to extracted JSON
*
* @access public
* @param {object} json extracted
* @param {object} channel parsed XML
*/
var decorateItunes = function decorateItunes(json, channel) {
var items = channel.item || [],
entry = {};
if (channel['itunes:owner']) {
json.feed.itunes = {
owner: {
name: channel['itunes:owner'][0]['itunes:name'][0],
email: channel['itunes:owner'][0]['itunes:email'][0]
},
image: channel['itunes:image'][0].$.href
};
}
PODCAST_TOP_FIELDS.forEach(function(f) {
if (channel['itunes:' + f]) json.feed.itunes[f] = channel['itunes:' + f][0];
});
(items).forEach(function(item, index) {
entry = json.feed.entries[index];
PODCAST_ITEM_FIELDS.forEach(function(f) {
entry.itunes = entry.itunes || {};
if (item['itunes:' + f]) entry.itunes[f] = item['itunes:' + f][0];
});
json.feed.entries[index] = entry;
});
}
Parser.parseString = function(xml, callback) {

@@ -110,0 +173,0 @@ XML2JS.parseString(xml, function(err, result) {

2

package.json
{
"name": "rss-parser",
"version": "2.3.0",
"version": "2.4.0",
"main": "index.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -16,4 +16,5 @@ {

"description": "1, 2, 1, 2… check the mic!",
"pubDate": "Fri, 13 May 2016 15:14:05 GMT",
"link": "https://localhost:8000"
}
}

@@ -280,2 +280,3 @@ {

],
"feedUrl": "https://www.reddit.com/.rss",
"title": "reddit: the front page of the internet",

@@ -282,0 +283,0 @@ "description": "",

@@ -280,2 +280,3 @@ {

],
"feedUrl": "https://www.reddit.com/.rss",
"title": "reddit: the front page of the internet",

@@ -282,0 +283,0 @@ "description": "",

@@ -67,2 +67,5 @@ var FS = require('fs');

});
it('should parse podcasts', function(done) {
testParseForFile('narro', 'rss', done);
});
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc