links
This commit is contained in:
parent
c8130afd5c
commit
dd5f6a4538
|
@ -2,16 +2,22 @@ import React from "react";
|
|||
import "./style.css";
|
||||
|
||||
const ChatBoxMessages = (props) => {
|
||||
var URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi;
|
||||
|
||||
|
||||
function Text(content) {
|
||||
|
||||
const words = content.split(' ');
|
||||
return(
|
||||
{words.map( (word) => ({
|
||||
return word.match(URL_REGEX) ? (<a href={word}>{word}</a>{' '})
|
||||
: (word + ' ');})}
|
||||
<p>
|
||||
{words.map((word) => {
|
||||
return word.startsWith('http') ? (
|
||||
<>
|
||||
<a href={word}>{word}</a>{' '}
|
||||
</>
|
||||
) : (
|
||||
word + ' '
|
||||
);
|
||||
})}
|
||||
</p>
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue