Permalink
Browse files

Bump version. Fix issue #25; add test. Add ability to pass "strict" b…

…oolean option to Sax.
  • Loading branch information...
1 parent eb8c744 commit 0a36817948cdb3a7c6f5ce5b94d820dcb250c2b4 @danmactough committed Oct 5, 2012
Showing with 26 additions and 4 deletions.
  1. +2 −1 { → bin}/dump.js
  2. +3 −2 main.js
  3. +4 −1 package.json
  4. +17 −0 test/notaFeed.js
View
3 dump.js → bin/dump.js 100644 → 100755
@@ -1,11 +1,12 @@
+#!/usr/bin/env node
/*
* Parse a feed and dump the result to the console
*
* Usage: node dump.js <feed url or filename>
*
*/
var util = require('util')
- , FeedParser = require('./')
+ , FeedParser = require('../')
, parser = new FeedParser()
, file = process.argv[2];
View
@@ -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); });
View
@@ -1,7 +1,7 @@
{ "name" : "feedparser"
, "author" : "Dan MacTough <danmactough@gmail.com>"
, "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"
+ }
}
View
@@ -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();
+ });
+ });
+ });
+});

0 comments on commit 0a36817

Please sign in to comment.