Skip to content

Commit

Permalink
refactor: utilize encodeURL of hexo-util
Browse files Browse the repository at this point in the history
  • Loading branch information
curbengh committed Oct 7, 2019
1 parent c6190ca commit d5fb012
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/plugins/helper/open_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d5fb012

Please sign in to comment.