Skip to content

Commit

Permalink
Fixes meta generator detection
Browse files Browse the repository at this point in the history
  • Loading branch information
h404bi committed Apr 20, 2018
1 parent 017d355 commit 3ed25c9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/plugins/filter/meta_generator.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use strict';

const rMetaGenerator = /<meta\s+name=['|"]?generator['|"]?/i;
const hexoGeneratorTag = '<meta name="generator" content="Hexo %s" />';
let cheerio;
const hexoGeneratorTag = '<meta name="generator" content="Hexo %s" />';

function hexoMetaGeneratorInject(data) {
if (!rMetaGenerator.test(data)) {
if (!cheerio) cheerio = require('cheerio');
const $ = cheerio.load(data, {decodeEntities: false});
if (!cheerio) cheerio = require('cheerio');
const $ = cheerio.load(data, {decodeEntities: false});

if (!($('meta[name="generator"]').length > 0)) {
$('head').prepend(hexoGeneratorTag.replace('%s', this.version));

return $.html();
Expand Down

0 comments on commit 3ed25c9

Please sign in to comment.