From 65bdee128ecfa3e03a2fd5a4fd4a22f344d3c045 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 26 Apr 2024 15:32:49 +0200 Subject: [PATCH] create hasURL --- src/libs/Url.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libs/Url.ts b/src/libs/Url.ts index 4e3282e7bdb3..80ca98c712cf 100644 --- a/src/libs/Url.ts +++ b/src/libs/Url.ts @@ -56,4 +56,10 @@ function appendParam(url: string, paramName: string, paramValue: string) { return `${url}${separator}${paramName}=${paramValue}`; } -export {addTrailingForwardSlash, hasSameExpensifyOrigin, getPathFromURL, appendParam}; +function hasURL(text: string) { + const urlPattern = /((https|http)?:\/\/[^\s]+)/g; + + return urlPattern.test(text); +} + +export {addTrailingForwardSlash, hasSameExpensifyOrigin, getPathFromURL, appendParam, hasURL};