Skip to content

Commit

Permalink
Merge 212afd8 into 9076422
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jul 25, 2020
2 parents 9076422 + 212afd8 commit c69d846
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/filter/after_render/meta_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function hexoMetaGeneratorInject(data) {

META_GENERATOR_TAG = META_GENERATOR_TAG || `<meta name="generator" content="Hexo ${this.version}">`;

return data.replace(/<head>(?!<\/head>).+?<\/head>/s, str => str.replace('</head>', `${META_GENERATOR_TAG}</head>`));
return data.replace('</head>', `${META_GENERATOR_TAG}</head>`);
}

module.exports = hexoMetaGeneratorInject;
26 changes: 0 additions & 26 deletions test/scripts/filters/meta_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,6 @@ describe('Meta Generator', () => {
should.not.exist(metaGenerator('<head><link><meta content="foo" name="generator"></head>'));
});

it('ignore empty head tag', () => {
const content = '<head></head><head><link></head><head></head>';
hexo.config.meta_generator = true;
const result = metaGenerator(content);

const $ = cheerio.load(result);
$('meta[name="generator"]').should.have.lengthOf(1);

const expected = '<head></head><head><link><meta name="generator" content="Hexo '
+ hexo.version + '"></head><head></head>';
result.should.eql(expected);
});

it('apply to first non-empty head tag only', () => {
const content = '<head></head><head><link></head><head><link></head>';
hexo.config.meta_generator = true;
const result = metaGenerator(content);

const $ = cheerio.load(result);
$('meta[name="generator"]').should.have.lengthOf(1);

const expected = '<head></head><head><link><meta name="generator" content="Hexo '
+ hexo.version + '"></head><head><link></head>';
result.should.eql(expected);
});

// Test for Issue #3777
it('multi-line head', () => {
const content = '<head>\n<link>\n</head>';
Expand Down

0 comments on commit c69d846

Please sign in to comment.