mirror of
https://github.com/wireadmin/wireadmin
synced 2025-06-26 18:28:06 +00:00
fix
This commit is contained in:
14
web/src/lib/utils/ip.ts
Normal file
14
web/src/lib/utils/ip.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export const IPV4_REGEX = new RegExp(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/);
|
||||
|
||||
/**
|
||||
* Private IP Address Identifier in Regular Expression
|
||||
*
|
||||
* 127. 0.0.0 – 127.255.255.255 127.0.0.0 /8
|
||||
* 10. 0.0.0 – 10.255.255.255 10.0.0.0 /8
|
||||
* 172. 16.0.0 – 172. 31.255.255 172.16.0.0 /12
|
||||
* 192.168.0.0 – 192.168.255.255 192.168.0.0 /16
|
||||
*/
|
||||
export function isPrivateIP(ip: string) {
|
||||
const ipRegex = /^(127\.)|(10\.)|(172\.1[6-9]\.)|(172\.2[0-9]\.)|(172\.3[0-1]\.)|(192\.168\.)/;
|
||||
return ipRegex.test(ip);
|
||||
}
|
||||
7
web/src/lib/utils/number.ts
Normal file
7
web/src/lib/utils/number.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function isBetween(v: any, n1: number, n2: number): boolean {
|
||||
if (Number.isNaN(v)) {
|
||||
return false;
|
||||
}
|
||||
const n = Number(v);
|
||||
return n1 <= n && n >= n2;
|
||||
}
|
||||
3
web/src/lib/utils/object.ts
Normal file
3
web/src/lib/utils/object.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export function isObject(obj: object) {
|
||||
return Object.prototype.toString.call(obj) === '[object Object]';
|
||||
}
|
||||
Reference in New Issue
Block a user