diff --git a/lib/plugins/helper/open_graph.js b/lib/plugins/helper/open_graph.js index 35d8beb12e..3f35ed82e4 100644 --- a/lib/plugins/helper/open_graph.js +++ b/lib/plugins/helper/open_graph.js @@ -115,7 +115,8 @@ function openGraphHelper(options = {}) { result += og('og:locale', localeToTerritory(language), false); } - images = images.map(path => new URL(path, url || config.url).toString()); + images = images.map(path => new URL(path, url || config.url).toString()) + .filter(url => !url.startsWith('data:')); images.forEach(path => { result += og('og:image', path, false); diff --git a/test/scripts/helpers/open_graph.js b/test/scripts/helpers/open_graph.js index c709e7fa17..be2fb2ecb1 100644 --- a/test/scripts/helpers/open_graph.js +++ b/test/scripts/helpers/open_graph.js @@ -211,6 +211,18 @@ describe('open_graph', () => { result.should.have.string(meta({property: 'og:image', content: 'https://hexo.io/test.jpg'})); }); + it('images - content with data-uri', () => { + const result = openGraph.call({ + page: { + content: '' + }, + config: hexo.config, + is_post: isPost + }); + + result.should.not.have.string(meta({property: 'og:image', content: 'data:image/svg+xml;utf8,...'})); + }); + it('images - string', () => { const result = openGraph.call({ page: {