2020-11-17 14:34:09 +01:00
|
|
|
export const SANITIZE_OPTIONS = {
|
|
|
|
allowedTags: [ 'a', 'p', 'span', 'br', 'strong', 'em', 'ul', 'ol', 'li' ],
|
|
|
|
allowedSchemes: [ 'http', 'https' ],
|
|
|
|
allowedAttributes: {
|
|
|
|
a: [ 'href', 'class', 'target', 'rel' ]
|
|
|
|
},
|
|
|
|
transformTags: {
|
2020-11-17 14:49:36 +01:00
|
|
|
a: (tagName: string, attribs: any) => {
|
2020-11-17 14:34:09 +01:00
|
|
|
let rel = 'noopener noreferrer'
|
|
|
|
if (attribs.rel === 'me') rel += ' me'
|
|
|
|
|
|
|
|
return {
|
|
|
|
tagName,
|
|
|
|
attribs: Object.assign(attribs, {
|
|
|
|
target: '_blank',
|
|
|
|
rel
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|