Skip to content

Commit

Permalink
Fix to avoid undefined content attribute on meta tags
Browse files Browse the repository at this point in the history
  • Loading branch information
dvonlehman committed Apr 23, 2016
1 parent a19a8bb commit 2f42af3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/attribute-modifier.js
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion 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": {
Expand Down
5 changes: 5 additions & 0 deletions test/.eslintrc
@@ -0,0 +1,5 @@
{
"rules": {
"max-len": [0, 150]
}
}
11 changes: 11 additions & 0 deletions test/attributes.js
Expand Up @@ -422,4 +422,15 @@ describe('htmlprep attributes', function() {
done();
});
});

it('does not append a content attribute to meta tags', function(done) {
var html = '<html><meta charset="UTF-8"/></html>';

run(html, {}, function(err, output) {
if (err) return done(err);

assert.equal(html, output);
done();
});
});
});
28 changes: 0 additions & 28 deletions test/htmlprep.js
Expand Up @@ -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;
// }

0 comments on commit 2f42af3

Please sign in to comment.