Skip to content

Commit

Permalink
refactor: update isExternalLink
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Nov 6, 2019
1 parent 878cf1b commit 60acb95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/plugins/filter/after_post_render/external_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const isExternal = (url, config) => {
const exclude = Array.isArray(config.external_link.exclude) ? config.external_link.exclude
: [config.external_link.exclude];
const data = urlObj(url);
const host = data.hostname;
const sitehost = typeof urlObj(config.url) === 'object' ? urlObj(config.url).hostname : config.url;
const sitehost = urlObj(config.url).hostname || config.url;

if (!sitehost || typeof data === 'string') return false;
if (data.origin === 'null') return false;

const host = data.hostname;
if (exclude && exclude.length) {
for (const i of exclude) {
if (host === i) return false;
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/filter/after_render/external_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ const isExternal = (url, config) => {
const exclude = Array.isArray(config.external_link.exclude) ? config.external_link.exclude
: [config.external_link.exclude];
const data = urlObj(url);
const host = data.hostname;
const sitehost = typeof urlObj(config.url) === 'object' ? urlObj(config.url).hostname : config.url;
const sitehost = urlObj(config.url).hostname || config.url;

if (!sitehost || typeof data === 'string') return false;
if (data.origin === 'null') return false;

const host = data.hostname;
if (exclude && exclude.length) {
for (const i of exclude) {
if (host === i) return false;
Expand Down

0 comments on commit 60acb95

Please sign in to comment.