diff --git a/lib/attribute-modifier.js b/lib/attribute-modifier.js index eca212c..01ce2ad 100644 --- a/lib/attribute-modifier.js +++ b/lib/attribute-modifier.js @@ -29,7 +29,7 @@ module.exports = function(options) { attribs.href = updateHrefAttribute(attribs.href); } - if (tagName === 'meta') { + if (tagName === 'meta' && attribs.content) { attribs.content = replaceBaseUrlPlaceholder(attribs.content); } diff --git a/package.json b/package.json index 5f419c4..98018bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "htmlprep", - "version": "1.6.2", + "version": "1.6.3", "description": "High-performance streaming HTML pre-processor designed to run in middleware.", "main": "index.js", "scripts": { diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 0000000..2cdf847 --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,5 @@ +{ + "rules": { + "max-len": [0, 150] + } +} diff --git a/test/attributes.js b/test/attributes.js index f2162c7..cba4942 100644 --- a/test/attributes.js +++ b/test/attributes.js @@ -422,4 +422,15 @@ describe('htmlprep attributes', function() { done(); }); }); + + it('does not append a content attribute to meta tags', function(done) { + var html = ''; + + run(html, {}, function(err, output) { + if (err) return done(err); + + assert.equal(html, output); + done(); + }); + }); }); diff --git a/test/htmlprep.js b/test/htmlprep.js index 8d2cb1e..135e4d0 100644 --- a/test/htmlprep.js +++ b/test/htmlprep.js @@ -283,31 +283,3 @@ describe('htmlprep()', function() { }); }); }); - -// function runProcessor(html, options, callback) { -// if (_.isFunction(options)) { -// callback = options; -// options = {}; -// } -// -// var output = ''; -// readStream(html).pipe(htmlprep(options)) -// .on('data', function(chunk) { -// output += chunk.toString(); -// }) -// .on('error', function(err) { -// return callback(err); -// }) -// .on('end', function() { -// callback(null, output); -// }); -// } -// -// function readStream(str) { -// var rs = stream.Readable(); -// rs._read = function() { -// rs.push(str); -// rs.push(null); -// }; -// return rs; -// }