fixing url pattern on mobile

This commit is contained in:
balzack 2025-03-26 23:15:06 -07:00
parent 38a637e5cb
commit d0e69246cc

View File

@ -61,6 +61,7 @@ export function Message({
useEffect(() => { useEffect(() => {
const urlPattern = new RegExp('(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,4}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)'); const urlPattern = new RegExp('(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,4}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)');
const hostPattern = new RegExp('^https?:\\/\\/', 'i'); const hostPattern = new RegExp('^https?:\\/\\/', 'i');
const dotPattern = new RegExp('^.*\\.\\..*$')
let plain = ''; let plain = '';
let clickable = []; let clickable = [];
@ -69,7 +70,7 @@ export function Message({
if (parsed?.length > 0) { if (parsed?.length > 0) {
const words = parsed as string[]; const words = parsed as string[];
words.forEach((word, index) => { words.forEach((word, index) => {
if (urlPattern.test(word)) { if (urlPattern.test(word) && !dotPattern.test(word)) {
clickable.push( clickable.push(
<Text key={index} style={textStyle}> <Text key={index} style={textStyle}>
{plain} {plain}