feature: vor und nachteile

This commit is contained in:
Hikyu
2026-05-31 13:54:31 +02:00
parent 552a947a1c
commit e3dad17446
23270 changed files with 3024794 additions and 200 deletions
+43
View File
@@ -0,0 +1,43 @@
import ipRegex from 'ip-regex';
import {isMatch} from 'super-regex';
const maxIPv4Length = 15;
const maxIPv6Length = 45;
const options = {
timeout: 400,
};
export function isIP(string) {
if (string.length > maxIPv6Length) {
return false;
}
return isMatch(ipRegex({exact: true}), string, options);
}
export function isIPv6(string) {
if (string.length > maxIPv6Length) {
return false;
}
return isMatch(ipRegex.v6({exact: true}), string, options);
}
export function isIPv4(string) {
if (string.length > maxIPv4Length) {
return false;
}
return isMatch(ipRegex.v4({exact: true}), string, options);
}
export function ipVersion(string) {
if (isIPv6(string)) {
return 6;
}
if (isIPv4(string)) {
return 4;
}
}