1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

formatting comment text

This commit is contained in:
muerwre 2019-08-27 21:49:20 +07:00
parent 1990783fa3
commit 59993f5beb
5 changed files with 27 additions and 4 deletions

View file

@ -55,4 +55,13 @@ export const describeArc = (
export const getURL = url => `${process.env.API_HOST}${url}`;
export const getImageSize = (image: string, size?: string): string =>
`${process.env.API_HOST}${image}`;
`${process.env.API_HOST}${image}`.replace('{size}', size);
export const formatCommentText = (author, text: string) =>
text
.replace(/(\n{2,})/gi, '\n')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.split('\n')
.map((el, index) => (index === 0 ? `<p><b>${author}</b>: ${el}</p>` : `<p>${el}</p>`))
.join('');