diff --git a/lib/plugins/filter/after_render/meta_generator.js b/lib/plugins/filter/after_render/meta_generator.js index 02f1efdf5c..d5e4f2c2f3 100644 --- a/lib/plugins/filter/after_render/meta_generator.js +++ b/lib/plugins/filter/after_render/meta_generator.js @@ -14,7 +14,7 @@ function hexoMetaGeneratorInject(data) { META_GENERATOR_TAG = META_GENERATOR_TAG || ``; - return data.replace(/
(?!<\/head>).+?<\/head>/s, str => str.replace('', `${META_GENERATOR_TAG}`)); + return data.replace('', `${META_GENERATOR_TAG}`); } module.exports = hexoMetaGeneratorInject; diff --git a/test/scripts/filters/meta_generator.js b/test/scripts/filters/meta_generator.js index 5df65a86c4..7d6078cedf 100644 --- a/test/scripts/filters/meta_generator.js +++ b/test/scripts/filters/meta_generator.js @@ -37,32 +37,6 @@ describe('Meta Generator', () => { should.not.exist(metaGenerator('')); }); - it('ignore empty head tag', () => { - const content = ''; - hexo.config.meta_generator = true; - const result = metaGenerator(content); - - const $ = cheerio.load(result); - $('meta[name="generator"]').should.have.lengthOf(1); - - const expected = ''; - result.should.eql(expected); - }); - - it('apply to first non-empty head tag only', () => { - const content = ''; - hexo.config.meta_generator = true; - const result = metaGenerator(content); - - const $ = cheerio.load(result); - $('meta[name="generator"]').should.have.lengthOf(1); - - const expected = ''; - result.should.eql(expected); - }); - // Test for Issue #3777 it('multi-line head', () => { const content = '\n\n';