diff --git a/.eslintrc b/.eslintrc index 91288aa..e8c26e0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,7 @@ { "extends": "hexo", - "root": true + "root": true, + "parserOptions": { + "ecmaVersion": 2018 + } } \ No newline at end of file diff --git a/lib/autodiscovery.js b/lib/autodiscovery.js index f22a3f5..4fcb262 100644 --- a/lib/autodiscovery.js +++ b/lib/autodiscovery.js @@ -12,7 +12,7 @@ function autodiscoveryInject(data) { const autodiscoveryTag = ``; - return data.replace(/
(?!<\/head>).+?<\/head>/, (str) => str.replace('', `${autodiscoveryTag}`)); + return data.replace(/(?!<\/head>).+?<\/head>/s, (str) => str.replace('', `${autodiscoveryTag}`)); } module.exports = autodiscoveryInject; diff --git a/package.json b/package.json index 5479f60..2b9f819 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,6 @@ "nyc": "14.1.1" }, "engines": { - "node": ">=8.6.0" + "node": ">=8.10.0" } } diff --git a/test/index.js b/test/index.js index d6f3768..50da595 100644 --- a/test/index.js +++ b/test/index.js @@ -333,6 +333,18 @@ describe('Autodiscovery', () => { $('link[rel="alternate"]').attr('type').should.eql('application/rss+xml'); result.should.eql(''); + + hexo.config.feed = { + type: 'atom', + path: 'atom.xml', + autodiscovery: true + }; }); + it('multi-line head tag', () => { + const content = '\n\n'; + const result = autoDiscovery(content); + + result.should.eql('\n\n'); + }); });