diff --git a/dump.js b/bin/dump.js old mode 100644 new mode 100755 similarity index 87% rename from dump.js rename to bin/dump.js index bb35fd9..87abfdf --- a/dump.js +++ b/bin/dump.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node /* * Parse a feed and dump the result to the console * @@ -5,7 +6,7 @@ * */ var util = require('util') - , FeedParser = require('./') + , FeedParser = require('../') , parser = new FeedParser() , file = process.argv[2]; diff --git a/main.js b/main.js index 71aa836..ba0ac60 100644 --- a/main.js +++ b/main.js @@ -98,7 +98,7 @@ function handleAttributes (attrs, el) { parser.in_xhtml = true; parser.xhtml = {'#name': el, '#': ''}; } - simplifiedAttributes[prefix + attr.local] = attr.value.trim(); + simplifiedAttributes[prefix + attr.local] = attr.value ? attr.value.trim() : ''; }); return simplifiedAttributes; } @@ -586,10 +586,11 @@ function FeedParser (options) { var parser = this; parser._reset(); parser.options = options || {}; + if (!('strict' in parser.options)) parser.options.strict = false; if (!('normalize' in parser.options)) parser.options.normalize = true; if (!('addmeta' in parser.options)) parser.options.addmeta = true; if (parser.options.feedurl) parser.xmlbase.unshift({ '#name': 'xml', '#': parser.options.feedurl}); - parser.stream = sax.createStream(false /* strict mode - no */, {lowercase: true, xmlns: true }); // https://github.com/isaacs/sax-js + parser.stream = sax.createStream(parser.options.strict /* strict mode - no by default */, {lowercase: true, xmlns: true }); // https://github.com/isaacs/sax-js parser.stream.on('error', function (e){ parser.handleSaxError(e, parser); }); parser.stream.on('opentag', function (n){ parser.handleOpenTag(n, parser); }); parser.stream.on('closetag', function (el){ parser.handleCloseTag(el, parser); }); diff --git a/package.json b/package.json index 14953a8..48392c0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "feedparser" , "author" : "Dan MacTough " , "description" : "Robust RSS Atom and RDF feed parsing using sax js" -, "version": "0.10.0-beta" +, "version": "0.10.1" , "keywords" : ["rss", "feed", "atom", "rdf", "xml", "syndication"] , "homepage" : "http://github.com/danmactough/node-feedparser" , "repository" : @@ -20,4 +20,7 @@ , "devDependencies": { "mocha" : "1.3.x" } +, "scripts": + { "test" : "./node_modules/mocha/bin/mocha --reporter list" + } } diff --git a/test/notaFeed.js b/test/notaFeed.js new file mode 100644 index 0000000..c7336e7 --- /dev/null +++ b/test/notaFeed.js @@ -0,0 +1,17 @@ +var assert = require('assert') + , FeedParser = require('../') + , feedparser = new FeedParser() + ; + +describe('feedparser', function(){ + describe('#parseUrl', function(){ + it('should not throw', function(done) { + this.timeout(10000); + feedparser.parseUrl('http://lifehacker.com', function (error, meta, articles) { + assert.ifError(error); + assert.equal(articles.length, 0); + done(); + }); + }); + }); +});