fix: clean link unit test resolved

This commit is contained in:
Harshit Anand
2023-10-10 01:05:55 +05:30
parent 2a9eb7f123
commit c279a9f9ed

View File

@@ -30,7 +30,7 @@ export const removeScript = (txt: string): string => {
DOMPurify.addHook('afterSanitizeAttributes', function (node) { DOMPurify.addHook('afterSanitizeAttributes', function (node) {
// set all elements owning target to target=_blank // set all elements owning target to target=_blank
if ('target' in node) { if (node.tagName === 'A' && node.hasAttribute('href') && 'target' in node) {
node.setAttribute('target', '_blank'); node.setAttribute('target', '_blank');
node.setAttribute('rel', 'noopener noreferrer'); node.setAttribute('rel', 'noopener noreferrer');
} }