Comparing version 0.0.9 to 0.0.10
@@ -6,3 +6,3 @@ //feed.js | ||
URL = require('url'), | ||
iconv = require('iconv-lite'); | ||
Iconv = require('iconv').Iconv; | ||
/** | ||
@@ -25,3 +25,5 @@ All you need to do is send a feed URL that can be opened via fs | ||
followRedirect: true, | ||
timeout: 1000 * 30 | ||
timeout: 1000 * 30, | ||
encoding: null, | ||
rssEncoding: 'UTF-8' | ||
}; | ||
@@ -45,5 +47,5 @@ options = _.extend(defaults, options); | ||
} else { | ||
var encodedXml = iconv.decode(new Buffer(xml), 'ISO-8859-1'); | ||
parseString(encodedXml, options, callback); | ||
//issues22 | ||
var iconv = new Iconv(options.rssEncoding, 'UTF-8'); | ||
xml = iconv.convert(xml).toString(); | ||
parseString(xml, options, callback); | ||
} | ||
@@ -77,5 +79,5 @@ } else { | ||
if (isRSS(jsonDOM)) { | ||
output = formatRSS(jsonDOM); | ||
output = formatRSS(jsonDOM, options); | ||
} else { | ||
output = formatATOM(jsonDOM); | ||
output = formatATOM(jsonDOM, options); | ||
} | ||
@@ -120,3 +122,3 @@ callback(null, output); | ||
//also parses FeedBurner | ||
function formatRSS(json) { | ||
function formatRSS(json, options) { | ||
var output = { | ||
@@ -158,2 +160,5 @@ 'type': 'rss', | ||
//Tx PaulFreund | ||
if ((options || {}).pipeOriginal) { | ||
obj.original = val; | ||
} | ||
obj.title = (_ref = val.title) != undefined && _ref.length > 0 ? _ref[0] : void 0; | ||
@@ -165,3 +170,3 @@ obj.summary = (_ref = val.description) != undefined && _ref.length > 0 ? _ref[0] : void 0; | ||
if (!(obj.summary != null) || obj.summary === '') { | ||
obj.summary = (_ref = val.comments[0]) ? _ref : ''; | ||
obj.summary = (_ref = (val.comments && val.comments[0])) ? _ref : ''; | ||
} | ||
@@ -207,3 +212,3 @@ //since we are going to format the date, we want to make sure it exists | ||
//formats the ATOM feed to the needed output | ||
function formatATOM(json) { | ||
function formatATOM(json, options) { | ||
var output = { | ||
@@ -253,2 +258,5 @@ 'type': 'atom', | ||
var obj = {}, _ref; | ||
if ((options || {}).pipeOriginal) { | ||
obj.original = val; | ||
} | ||
obj.id = val.id[0]; | ||
@@ -353,2 +361,2 @@ obj.title = (_ref = val.title) != undefined && _ref.length > 0 ? _ref[0]._ : void 0; | ||
} | ||
}; | ||
}; |
@@ -6,6 +6,13 @@ { | ||
"dependencies": { | ||
"iconv-lite": { | ||
"version": "0.4.4", | ||
"from": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.4.tgz", | ||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.4.tgz" | ||
"iconv": { | ||
"version": "2.1.4", | ||
"from": "iconv@2.1.4", | ||
"resolved": "https://registry.npmjs.org/iconv/-/iconv-2.1.4.tgz", | ||
"dependencies": { | ||
"nan": { | ||
"version": "1.1.2", | ||
"from": "nan@1.1.2", | ||
"resolved": "https://registry.npmjs.org/nan/-/nan-1.1.2.tgz" | ||
} | ||
} | ||
}, | ||
@@ -12,0 +19,0 @@ "request": { |
{ | ||
"name": "rssparser", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"author": "Arjunkumar Krishnamoorthy", | ||
"contributors": [ | ||
"Javier Scappini", | ||
"Andrija Vucinic" | ||
], | ||
"description": "rssparser is an all purpose RSS/ATOM feed parser that parses feeds into a JSON format.", | ||
@@ -23,3 +27,3 @@ "keywords": [ | ||
"underscore": ">=1.3.3", | ||
"iconv-lite": ">=0.4.4" | ||
"iconv": ">=2.1.4" | ||
}, | ||
@@ -35,4 +39,4 @@ "devDependencies": { | ||
"readmeFilename": "README.md", | ||
"_id": "rssparser@0.0.9", | ||
"_id": "rssparser@0.0.10", | ||
"_from": "rssparser" | ||
} |
@@ -6,3 +6,4 @@ node-rssparser [![endorse](https://api.coderwall.com/tk120404/endorsecount.png)](https://coderwall.com/tk120404) | ||
[![build status](https://secure.travis-ci.org/tk120404/node-rssparser.png)](http://travis-ci.org/tk120404/node-rssparser) [![NPM](https://nodei.co/npm/rssparser.png)](https://nodei.co/npm/rssparser/) ![NPM](https://nodei.co/npm-dl/rssparser.png) | ||
[![build status](https://secure.travis-ci.org/tk120404/node-rssparser.png)](http://travis-ci.org/tk120404/node-rssparser)[![Code Climate](https://codeclimate.com/github/tk120404/node-rssparser.png)](https://codeclimate.com/github/tk120404/node-rssparser) | ||
[![NPM](https://nodei.co/npm/rssparser.png)](https://nodei.co/npm/rssparser/) ![NPM](https://nodei.co/npm-dl/rssparser.png) | ||
@@ -9,0 +10,0 @@ Installing |
@@ -60,3 +60,18 @@ // string test.js | ||
} | ||
}, | ||
'verbose mode': { | ||
'it adds the original items': { | ||
topic: function () { | ||
parser.parseURL( | ||
'http://www.espnscrum.com/rss/rugby/rss/headlines_fantasy.rss', | ||
{ pipeOriginal: true }, | ||
this.callback | ||
); | ||
}, | ||
'returns the complete item': function (err, docs) { | ||
assert.isNull(err); | ||
assert.isObject(docs.items[0].original); | ||
} | ||
} | ||
} | ||
}).export(module); |
Sorry, the diff of this file is not supported yet
23832
7
561
105
+ Addediconv@>=2.1.4
+ Addediconv@3.0.1(transitive)
- Removediconv-lite@>=0.4.4
- Removediconv-lite@0.6.3(transitive)