aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/helpers/utils/html.ts
blob: 2d520aee92e90a832523cce755737b08629d9533 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { immutableAssign } from './object'

function objectLineFeedToHtml (obj: any, keyToNormalize: string) {
  return immutableAssign(obj, {
    [keyToNormalize]: lineFeedToHtml(obj[keyToNormalize])
  })
}

function lineFeedToHtml (text: string) {
  if (!text) return text

  return text.replace(/\r?\n|\r/g, '<br />')
}

export {
  objectLineFeedToHtml,
  lineFeedToHtml
}