From 14cc3edde3fa53f241efe82b8953a72e34f5f383 Mon Sep 17 00:00:00 2001 From: MDLeom <43627182+curbengh@users.noreply.github.com> Date: Sat, 15 Aug 2020 08:49:39 +0000 Subject: [PATCH] fix(image): remove unnecessary hostname check - checked by url_for() * https://github.com/hexojs/hexo-util/blob/b34456a7a56ae905c13a3541272176ef520a0488/lib/url_for.js#L31 --- lib/renderer.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/renderer.js b/lib/renderer.js index 45715ea..59c1bfa 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -3,7 +3,6 @@ const marked = require('marked'); const { encodeURL, slugize, stripHTML, url_for, isExternalLink } = require('hexo-util'); const MarkedRenderer = marked.Renderer; -const { parse } = require('url'); const { sep } = require('path'); let hexo; @@ -93,16 +92,15 @@ class Renderer extends MarkedRenderer { const { relative_link } = hexo.config; const { options } = this; const { lazyload, prependRoot, postId } = options; - const { hostname } = parse(href); - if (!hostname && !relative_link && prependRoot) { + if (!relative_link && prependRoot) { if (postId) { const PostAsset = hexo.model('PostAsset'); // slug requires platform-specific path const asset = PostAsset.findOne({ post: postId, slug: href.replace(/\/|\\/g, sep) }); if (asset) href = encodeURL(('/' + asset.path).replace(/\\/g, '/').replace(/\/{2,}/g, '/')); } - href = url_for.call(options, href); + href = url_for.call(hexo, href); } let out = `