Skip to content

Commit

Permalink
Bump version. Fix issue #25; add test. Add ability to pass "strict" b…
Browse files Browse the repository at this point in the history
…oolean option to Sax.
  • Loading branch information
danmactough committed Oct 5, 2012
1 parent eb8c744 commit 0a36817
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
3 changes: 2 additions & 1 deletion 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];

Expand Down
5 changes: 3 additions & 2 deletions main.js
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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); });
Expand Down
5 changes: 4 additions & 1 deletion package.json
@@ -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" :
Expand All @@ -20,4 +20,7 @@
, "devDependencies":
{ "mocha" : "1.3.x"
}
, "scripts":
{ "test" : "./node_modules/mocha/bin/mocha --reporter list"
}
}
17 changes: 17 additions & 0 deletions 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();
});
});
});
});

0 comments on commit 0a36817

Please sign in to comment.