Skip to content

Commit

Permalink
fix(external_link): handle whatwg url api
Browse files Browse the repository at this point in the history
Apply code suggestions from code review by @curbengh
  • Loading branch information
SukkaW committed Oct 28, 2019
1 parent ab23935 commit ec465a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/plugins/filter/after_post_render/external_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ const isExternal = (url, config) => {
[config.external_link.exclude];
const data = urlObj(url);
const host = data.hostname;
const sitehost = urlObj(config.url).hostname || config.url;
const sitehost = typeof urlObj(config.url) === 'object' ? urlObj(config.url).hostname : config.url;

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

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

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

if (exclude && exclude.length) {
for (const i of exclude) {
Expand Down

0 comments on commit ec465a5

Please sign in to comment.