diff --git a/src/components/modules/violations/ViolationDetails.js b/src/components/modules/violations/ViolationDetails.js index 0c0acf2..ce6a530 100644 --- a/src/components/modules/violations/ViolationDetails.js +++ b/src/components/modules/violations/ViolationDetails.js @@ -23,7 +23,11 @@ import { TableStyle } from '../Profile' import styled from 'styled-components' import CommentSection from './CommentSection' -import { formatDateShort, formatTime } from '../../utils/Util' +import { + formatDateShort, + formatTime, + formatTextWithLinks, +} from '../../utils/Util' import PublishModal from './PublishModal' const UpdatesTable = styled(TableStyle)` @@ -378,7 +382,12 @@ export default (props) => {

Описание

-

{data.description}

+


{!data.publishedText ? null : ( <> diff --git a/src/components/utils/Util.js b/src/components/utils/Util.js index c2e692b..745fd09 100644 --- a/src/components/utils/Util.js +++ b/src/components/utils/Util.js @@ -135,6 +135,15 @@ const checkPaths = (path1, path2) => { return path1 === path2 } +const formatTextWithLinks = (text) => { + const urlRegex = /(https?:\/\/[^\s]+)/g + return text.replace( + urlRegex, + (url) => + `${url}` + ) +} + module.exports = { formatLv, formatPop, @@ -146,4 +155,5 @@ module.exports = { format, checkPaths, mapRoleLocalization, + formatTextWithLinks, }