Better url regex

This commit is contained in:
Piotr Rogowski 2023-08-10 13:30:09 +02:00
parent 62da1247da
commit cb6d31110c
No known key found for this signature in database
GPG Key ID: 4A842D702D9C6F8F
1 changed files with 3 additions and 3 deletions

View File

@ -9,9 +9,9 @@ const TextField = ({ title }: { title: string }) => {
const message = type ? title.substring(1) : title;
let messageTag = <span>{message}</span>;
// check if message contains a link and render it as a link
const linkRegex = /https?:\/\/[^\s]+/g;
const linkMatch = message.match(linkRegex);
// check if message contains url and render it as a link
const linkMatch = message.match(/https?:\/\/[^:[\]@!$'(),; ]+/g);
if (linkMatch) {
const link = linkMatch[0];
const linkIndex = message.indexOf(link);