diff --git a/lib/plugins/filter/after_post_render/external_link.js b/lib/plugins/filter/after_post_render/external_link.js index a056a5a525..e8297de1df 100644 --- a/lib/plugins/filter/after_post_render/external_link.js +++ b/lib/plugins/filter/after_post_render/external_link.js @@ -3,8 +3,8 @@ const { parse } = require('url'); const isExternal = (url, config) => { - const exclude = Array.isArray(config.external_link.exclude) ? config.external_link.exclude : - [config.external_link.exclude]; + const exclude = Array.isArray(config.external_link.exclude) ? config.external_link.exclude + : [config.external_link.exclude]; const data = parse(url); const host = data.hostname; const sitehost = parse(config.url).hostname || config.url; @@ -25,16 +25,16 @@ const isExternal = (url, config) => { function externalLinkFilter(data) { const { config } = this; - if (typeof config.external_link === 'undefined' || typeof config.external_link === 'object' || - config.external_link === true) { + if (typeof config.external_link === 'undefined' || typeof config.external_link === 'object' + || config.external_link === true) { config.external_link = Object.assign({ enable: true, field: 'site', exclude: '' }, config.external_link); } - if (config.external_link === false || config.external_link.enable === false || - config.external_link.field !== 'post') return; + if (config.external_link === false || config.external_link.enable === false + || config.external_link.field !== 'post') return; data.content = data.content.replace(//gi, (str, hrefStr, href) => { if (/target=/gi.test(str) || !isExternal(href, config)) return str; diff --git a/lib/plugins/filter/after_render/external_link.js b/lib/plugins/filter/after_render/external_link.js index fd3d7b4ea8..1854944ef3 100644 --- a/lib/plugins/filter/after_render/external_link.js +++ b/lib/plugins/filter/after_render/external_link.js @@ -9,8 +9,8 @@ const { parse } = require('url'); * @returns {Boolean} True if the link doesn't have protocol or link has same host with config.url */ const isExternal = (url, config) => { - const exclude = Array.isArray(config.external_link.exclude) ? config.external_link.exclude : - [config.external_link.exclude]; + const exclude = Array.isArray(config.external_link.exclude) ? config.external_link.exclude + : [config.external_link.exclude]; const data = parse(url); const host = data.hostname; const sitehost = parse(config.url).hostname || config.url; @@ -31,16 +31,16 @@ const isExternal = (url, config) => { function externalLinkFilter(data) { const { config } = this; - if (typeof config.external_link === 'undefined' || typeof config.external_link === 'object' || - config.external_link === true) { + if (typeof config.external_link === 'undefined' || typeof config.external_link === 'object' + || config.external_link === true) { config.external_link = Object.assign({ enable: true, field: 'site', exclude: '' }, config.external_link); } - if (config.external_link === false || config.external_link.enable === false || - config.external_link.field !== 'site') return; + if (config.external_link === false || config.external_link.enable === false + || config.external_link.field !== 'site') return; data = data.replace(//gi, (str, hrefStr, href) => { if (/target=/gi.test(str) || !isExternal(href, config)) return str;