Skip to content

Commit

Permalink
Fix hydration mismatch due to different order of attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed Apr 9, 2022
1 parent eee5891 commit 897c585
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ export function handleCommentClick(event: ReactMouseEvent<HTMLElement, MouseEven

export function processCommentBody(bodyHTML: string) {
if (typeof document === 'undefined') {
return bodyHTML.replace(/<a href/g, '<a target="_top" rel="noopener noreferrer nofollow" href');
return bodyHTML.replace(
/<a (href="[^"]*")/g,
'<a $1 rel="noopener noreferrer nofollow" target="_top"',
);
}

const template = document.createElement('template');
Expand All @@ -164,8 +167,8 @@ export function processCommentBody(bodyHTML: string) {
return;
}

a.target = '_top';
a.rel = 'noopener noreferrer nofollow';
a.target = '_top';
});

content
Expand Down

1 comment on commit 897c585

@vercel
Copy link

@vercel vercel bot commented on 897c585 Apr 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.