diff --git a/src/utils/common.ts b/src/utils/common.ts index 4ea548e..d7553b8 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -7,3 +7,8 @@ export function handleAxiosError(error: AxiosError) { export function enumKeys(obj: O): K[] { return Object.keys(obj).filter(k => Number.isNaN(+k)) as K[]; } + +export function isUrl(val: string): boolean { + var urlPattern = /^https:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/; + return urlPattern.test(val); +} \ No newline at end of file diff --git a/src/utils/index.ts b/src/utils/index.ts index 49c639a..e8acf60 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,8 +1,9 @@ import useAutosizeTextArea from "./useAutosizeTextArea"; -import { handleAxiosError, enumKeys } from "./common"; +import { handleAxiosError, enumKeys, isUrl } from "./common"; export { useAutosizeTextArea, handleAxiosError, enumKeys, + isUrl } \ No newline at end of file