mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-25 13:59:36 +02:00
Added support for setting icons via URL
This commit is contained in:
parent
d83e3056c6
commit
f5ed85427e
5 changed files with 46 additions and 14 deletions
25
client/src/utility/validators.ts
Normal file
25
client/src/utility/validators.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
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);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue