mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 10:23:33 +00:00
sanitize album artist biography
This commit is contained in:
parent
24394fa858
commit
7bebe286d5
5 changed files with 385 additions and 18 deletions
16
src/renderer/utils/sanitize.ts
Normal file
16
src/renderer/utils/sanitize.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import sanitizeHtml, { IOptions, simpleTransform } from 'sanitize-html';
|
||||
|
||||
const SANITIZE_OPTIONS: IOptions = {
|
||||
allowedAttributes: {
|
||||
a: ['href', 'rel', 'target'],
|
||||
},
|
||||
allowedSchemes: ['http', 'https', 'mailto'],
|
||||
allowedTags: ['a', 'b', 'div', 'em', 'i', 'p', 'strong'],
|
||||
transformTags: {
|
||||
a: simpleTransform('a', { rel: 'noopener noreferrer', target: '_blank' }),
|
||||
},
|
||||
};
|
||||
|
||||
export const sanitize = (text: string): string => {
|
||||
return sanitizeHtml(text, SANITIZE_OPTIONS);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue