Skip to content

Commit

Permalink
[fix] convert xml to string before calling .trim
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-pmb committed Jan 2, 2017
1 parent 32b6dde commit c28c2da
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = parse;
*/

function parse(xml) {
xml = xml.trim();
xml = String(xml).trim();

// strip comments
xml = xml.replace(/<!--[\s\S]*?-->/g, '');
Expand All @@ -32,10 +32,14 @@ function parse(xml) {
*/

function document() {
return {
declaration: declaration(),
root: tag()
var doc = { declaration: declaration() }, moreDecl;
while (true) {
moreDecl = declaration();
if (!moreDecl) { break; }
doc.declaration += moreDecl;
}
doc.root = tag();
return doc;
}

/**
Expand Down

0 comments on commit c28c2da

Please sign in to comment.