links
This commit is contained in:
parent
c8130afd5c
commit
dd5f6a4538
|
@ -2,17 +2,23 @@ import React from "react";
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
|
|
||||||
const ChatBoxMessages = (props) => {
|
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) {
|
function Text(content) {
|
||||||
|
|
||||||
const words = content.split(' ');
|
const words = content.split(' ');
|
||||||
return (
|
return(
|
||||||
{words.map( (word) => ({
|
<p>
|
||||||
return word.match(URL_REGEX) ? (<a href={word}>{word}</a>{' '})
|
{words.map((word) => {
|
||||||
: (word + ' ');})}
|
return word.startsWith('http') ? (
|
||||||
);
|
<>
|
||||||
|
<a href={word}>{word}</a>{' '}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
word + ' '
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue