diff --git a/lib/plugins/helper/open_graph.js b/lib/plugins/helper/open_graph.js index a97436dae0..c3100a9ee6 100644 --- a/lib/plugins/helper/open_graph.js +++ b/lib/plugins/helper/open_graph.js @@ -2,7 +2,7 @@ const urlFn = require('url'); const moment = require('moment'); -const { escapeHTML, htmlTag, stripHTML } = require('hexo-util'); +const { encodeURL, escapeHTML, htmlTag, stripHTML } = require('hexo-util'); function meta(name, content, escape) { if (escape !== false && typeof content === 'string') { @@ -90,13 +90,7 @@ function openGraphHelper(options = {}) { url = url.replace(/index\.html$/, ''); } - if (url) { - url = urlFn.format({ - protocol: urlFn.parse(url).protocol, - hostname: urlFn.parse(url).hostname, - pathname: encodeURI(urlFn.parse(url).pathname) - }); - } + if (url) url = encodeURL(url); result += og('og:url', url, false); result += og('og:site_name', siteName);