This commit is contained in:
ahmed531998 2023-04-19 18:48:26 +02:00
parent c8130afd5c
commit dd5f6a4538
1 changed files with 14 additions and 8 deletions

View File

@ -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 (