fix: link nofollow

This commit is contained in:
shuai 2023-04-10 16:25:12 +08:00
parent e8034334fb
commit 81d58431d5
2 changed files with 3 additions and 2 deletions

View File

@ -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) {

View File

@ -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';
}
});