fix: Render links with target attribute (#4685)

This commit is contained in:
Pranav Raj S 2022-05-16 11:29:05 +05:30 committed by GitHub
parent 2060f270d3
commit 45e2cd4903
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 11 deletions

View file

@ -6,3 +6,15 @@ export const escapeHtml = (unsafe = '') => {
.replace(/"/g, '"')
.replace(/'/g, ''');
};
export const afterSanitizeAttributes = currentNode => {
if ('target' in currentNode) {
currentNode.setAttribute('target', '_blank');
}
};
export const domPurifyConfig = {
hooks: {
afterSanitizeAttributes,
},
};