Skip to content

Commit

Permalink
refactor: use startsWith instead of regex
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Oct 27, 2019
1 parent 9ff66ed commit 3222513
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/plugins/filter/after_post_render/external_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function externalLinkFilter(data) {
config.external_link.field !== 'post') return;

data.content = data.content.replace(/<a.*?(href=['"](.*?)['"]).*?>/gi, (str, hrefStr, href) => {
if (/target=/gi.test(str) || /mailto:|javascript:/gi.test(href) || !isExternal(href, config)) return str;
if (/target=/gi.test(str) || href.startsWith('mailto:') || href.startsWith('javascript:') || !isExternal(href, config)) return str;

if (/rel=/gi.test(str)) {
str = str.replace(/rel="(.*?)"/gi, (relStr, rel) => {
Expand Down

0 comments on commit 3222513

Please sign in to comment.