aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/core-utils/renderer/html.ts
blob: 1220848a0a2cc4fcbb45ebebd8d9fb37f25ab9fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export const SANITIZE_OPTIONS = {
  allowedTags: [ 'a', 'p', 'span', 'br', 'strong', 'em', 'ul', 'ol', 'li' ],
  allowedSchemes: [ 'http', 'https' ],
  allowedAttributes: {
    a: [ 'href', 'class', 'target', 'rel' ]
  },
  transformTags: {
    a: (tagName: string, attribs: any) => {
      let rel = 'noopener noreferrer'
      if (attribs.rel === 'me') rel += ' me'

      return {
        tagName,
        attribs: Object.assign(attribs, {
          target: '_blank',
          rel
        })
      }
    }
  }
}