mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-20 03:59:36 +02:00
26 lines
935 B
TypeScript
26 lines
935 B
TypeScript
|
export const isUrlOrIp = (data: string): boolean => {
|
||
|
const regex =
|
||
|
/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?|^((http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i;
|
||
|
|
||
|
return regex.test(data);
|
||
|
};
|
||
|
|
||
|
export const isUrl = (data: string): boolean => {
|
||
|
const regex =
|
||
|
/(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/i;
|
||
|
|
||
|
return regex.test(data);
|
||
|
};
|
||
|
|
||
|
export const isImage = (data: string): boolean => {
|
||
|
const regex = /.(jpeg|jpg|png)$/i;
|
||
|
|
||
|
return regex.test(data);
|
||
|
};
|
||
|
|
||
|
export const isSvg = (data: string): boolean => {
|
||
|
const regex = /.(svg)$/i;
|
||
|
|
||
|
return regex.test(data);
|
||
|
};
|