Skip to content

Commit

Permalink
Merge pull request #1 from celer/master
Browse files Browse the repository at this point in the history
Fix for callback being a global variable
  • Loading branch information
Nicholas Penree committed Jul 16, 2011
2 parents b59363c + b3317a9 commit a0b1c3f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/easyrss.js
Expand Up @@ -20,11 +20,12 @@
var http = require('http')
, xml = require('libxmljs')
, parseURL = require('url').parse
, options = {};



// The main "meat" of this module - parses an rss feed and triggers
// the callback when done.
var easyParser = function(callback) {
var easyParser = function(callback,options) {
var parser = new xml.SaxParser(function(cb) {
var articles = Array();
var current_element = false;
Expand Down Expand Up @@ -129,10 +130,11 @@ exports.parseFile = function(file, cb) {
*/

exports.parseURL = function(url, opts) {
if (typeof opts == 'function') {
options = { cb: opts };
} else {
options = opts;
var options={};
if(typeof opts=="function"){
options.cb = opts;
} else {
options=opts;
}

get_rss(url);
Expand All @@ -156,7 +158,7 @@ exports.parseURL = function(url, opts) {
var body = '';
response.addListener('data', function (chunk) { body += chunk; });
response.addListener('end', function() {
easyParser(options.cb).parseString(body);
easyParser(options.cb,options).parseString(body);
});
break;
// redirect status returned
Expand Down

0 comments on commit a0b1c3f

Please sign in to comment.