mirror of
https://github.com/balzack/databag.git
synced 2025-04-20 00:25:16 +00:00
fixing url pattern on mobile
This commit is contained in:
parent
38a637e5cb
commit
d0e69246cc
@ -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}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user