mirror of https://gitee.com/answerdev/answer.git
fix: link nofollow
This commit is contained in:
parent
e8034334fb
commit
81d58431d5
|
@ -32,7 +32,7 @@ const ActivateScriptNodes = (el, part) => {
|
|||
scriptList.push(node);
|
||||
}
|
||||
}
|
||||
scriptList.forEach((so) => {
|
||||
scriptList?.forEach((so) => {
|
||||
const script = document.createElement('script');
|
||||
script.text = so.text;
|
||||
for (let i = 0; i < so.attributes.length; i += 1) {
|
||||
|
|
|
@ -146,7 +146,8 @@ export function htmlRender(el: HTMLElement | null) {
|
|||
el.querySelectorAll('a').forEach((a) => {
|
||||
const base = window.location.origin;
|
||||
const targetUrl = new URL(a.href, base);
|
||||
if (targetUrl.toString() !== window.location.href) {
|
||||
|
||||
if (targetUrl.origin !== base) {
|
||||
a.rel = 'nofollow';
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue