feedparser
Advanced tools
Comparing version 0.19.0 to 0.19.1
@@ -25,26 +25,7 @@ /** | ||
req.on('response', function(res) { | ||
var stream = this | ||
, iconv | ||
, charset; | ||
if (res.statusCode != 200) return this.emit('error', new Error('Bad status code')); | ||
charset = getParams(res.headers['content-type'] || '').charset; | ||
// Use iconv if its not utf8 already. | ||
if (!iconv && charset && !/utf-*8/i.test(charset)) { | ||
try { | ||
iconv = new Iconv(charset, 'utf-8'); | ||
console.log('Converting from charset %s to utf-8', charset); | ||
iconv.on('error', done); | ||
// If we're using iconv, stream will be the output of iconv | ||
// otherwise it will remain the output of request | ||
stream = this.pipe(iconv); | ||
} catch(err) { | ||
this.emit('error', err); | ||
} | ||
} | ||
var charset = getParams(res.headers['content-type'] || '').charset; | ||
res = maybeTranslate(res, charset); | ||
// And boom goes the dynamite | ||
stream.pipe(feedparser); | ||
res.pipe(feedparser); | ||
}); | ||
@@ -62,2 +43,20 @@ | ||
function maybeTranslate (res, charset) { | ||
var iconv; | ||
// Use iconv if its not utf8 already. | ||
if (!iconv && charset && !/utf-*8/i.test(charset)) { | ||
try { | ||
iconv = new Iconv(charset, 'utf-8'); | ||
console.log('Converting from charset %s to utf-8', charset); | ||
iconv.on('error', done); | ||
// If we're using iconv, stream will be the output of iconv | ||
// otherwise it will remain the output of request | ||
res = res.pipe(iconv); | ||
} catch(err) { | ||
res.emit('error', err); | ||
} | ||
} | ||
return res; | ||
} | ||
function getParams(str) { | ||
@@ -64,0 +63,0 @@ var params = str.split(';').reduce(function (params, param) { |
v0.19.1 / 2014-07-31 | ||
================== | ||
* Add compressed example | ||
* Refactor iconv example | ||
v0.19.0 / 2014-07-30 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -5,3 +5,3 @@ { | ||
"description": "Robust RSS Atom and RDF feed parsing using sax js", | ||
"version": "0.19.0", | ||
"version": "0.19.1", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "rss", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
583385
40
1732
7
4