-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support wildcard domain #33
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,11 @@ function isExternal(url, config) { | |
|
||
if (exclude && exclude.length) { | ||
for (const i of exclude) { | ||
if (host === i) return false; | ||
if (i === host || (host && host.endsWith(i))) return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary repetition |
||
} | ||
} | ||
|
||
if (host !== sitehost) return true; | ||
if (sitehost !== host && (host && !host.endsWith(sitehost))) return true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For host to be null, it is recommended to use early return |
||
|
||
return false; | ||
} | ||
|
@@ -34,7 +34,7 @@ module.exports = function(data) { | |
return data.replace(/<a.*?(href=['"](.*?)['"]).*?>/gi, (str, hrefStr, href) => { | ||
if (!isExternal(href, config)) return str; | ||
|
||
let noFollow = ['noopener', 'external', 'nofollow', 'noreferrer']; | ||
let noFollow = ['external', 'nofollow', 'noreferrer', 'noopener']; | ||
|
||
if (/rel=/gi.test(str)) { | ||
str = str.replace(/\srel="(.*?)"/gi, (relStr, rel) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "hexo-filter-nofollow", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to modify it |
||
"description": "Add nofollow attribute to all external links automatically", | ||
"main": "index.js", | ||
"directories": { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.