Skip to content

Commit

Permalink
chore: merge branch 'fix/meta-tags'
Browse files Browse the repository at this point in the history
  • Loading branch information
remy committed Jan 18, 2016
2 parents e6c4a70 + 9b60777 commit cfcb0be
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ function main() {
if (enc !== 'utf-8') {
// when transcoding remove any meta tags setting the charset
$('meta').each(function charMeta() {
var content = $(this).attr('content') || '';
if (content.toLowerCase().indexOf('charset=')) {
var attrs = $(this).attr();
var content = attrs.content || '';
if (attrs.charset || content.toLowerCase().indexOf('charset=') !== -1) {
$(this).remove();
}
});
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/meta-tags-alt.opts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"encoding": "windows-1253"
}
1 change: 1 addition & 0 deletions test/fixtures/meta-tags-alt.result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width"> <meta name="description" content="just a demo"> <title>metatag test</title> </head> <body> <p>Nothing to see</p> </body> </html>
12 changes: 12 additions & 0 deletions test/fixtures/meta-tags-alt.src.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width">
<meta name="description" content="just a demo">
<title>metatag test</title>
</head>
<body>
<p>Nothing to see</p>
</body>
</html>
3 changes: 3 additions & 0 deletions test/fixtures/meta-tags.opts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"encoding": "windows-1253"
}
1 change: 1 addition & 0 deletions test/fixtures/meta-tags.result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width"> <meta name="description" content="just a demo"> <title>metatag test</title> </head> <body> <p>Nothing to see</p> </body> </html>
12 changes: 12 additions & 0 deletions test/fixtures/meta-tags.src.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta name="description" content="just a demo">
<title>metatag test</title>
</head>
<body>
<p>Nothing to see</p>
</body>
</html>
1 change: 1 addition & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ test('inliner fixtures', function fixtureTests(t) {
var opts = {};
try {
opts = require(optsfile);
debug('loaded options %s', optsfile, opts);
} catch (e) {}

return new Promise(function inlinerPromise(resolve, reject) {
Expand Down

0 comments on commit cfcb0be

Please sign in to comment.