Adds URL validation (#1155)

This commit is contained in:
Srikar Samudrala
2023-08-10 22:05:09 +05:30
committed by GitHub
parent c91844071a
commit ee5ac11f98
3 changed files with 48 additions and 0 deletions

10
front/src/utils/is-url.ts Normal file
View File

@ -0,0 +1,10 @@
import { isDefined } from './isDefined';
export function isURL(url: string | undefined | null) {
return (
isDefined(url) &&
/^((?!-))(xn--)?[a-z0-9][a-z0-9-_]{0,61}[a-z0-9]{0,1}\.(xn--)?([a-z0-9-]{1,61}|[a-z0-9-]{1,30}\.[a-z]{2,})$/.test(
url,
)
);
}