Skip to content

Commit

Permalink
style(external_link): operator-linebreak
Browse files Browse the repository at this point in the history
  • Loading branch information
curbengh committed Oct 18, 2019
1 parent c9f68b6 commit 3eba1fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions lib/plugins/filter/after_post_render/external_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(/<a.*?(href=['"](.*?)['"]).*?>/gi, (str, hrefStr, href) => {
if (/target=/gi.test(str) || !isExternal(href, config)) return str;
Expand Down
12 changes: 6 additions & 6 deletions lib/plugins/filter/after_render/external_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(/<a.*?(href=['"](.*?)['"]).*?>/gi, (str, hrefStr, href) => {
if (/target=/gi.test(str) || !isExternal(href, config)) return str;
Expand Down

0 comments on commit 3eba1fe

Please sign in to comment.