mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-08-05 21:35:14 +03:00
feat: Introduce fe modular build system
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
// This file is autogenerated, please don't change manually
|
||||
"use strict";
|
||||
"require baseclass";
|
||||
|
||||
// src/validators/validateIp.ts
|
||||
function validateIPV4(ip) {
|
||||
const ipRegex = /^(?:(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/;
|
||||
if (ipRegex.test(ip)) {
|
||||
return { valid: true, message: "Valid" };
|
||||
}
|
||||
return { valid: false, message: "Invalid IP address" };
|
||||
}
|
||||
|
||||
// src/validators/validateDomain.ts
|
||||
function validateDomain(domain) {
|
||||
const domainRegex = /^(?=.{1,253}(?:\/|$))(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9-]{1,59}[a-zA-Z0-9])(?:\/[^\s]*)?$/;
|
||||
if (!domainRegex.test(domain)) {
|
||||
return { valid: false, message: "Invalid domain address" };
|
||||
}
|
||||
const hostname = domain.split("/")[0];
|
||||
const parts = hostname.split(".");
|
||||
const atLeastOneInvalidPart = parts.some((part) => part.length > 63);
|
||||
if (atLeastOneInvalidPart) {
|
||||
return { valid: false, message: "Invalid domain address" };
|
||||
}
|
||||
return { valid: true, message: "Valid" };
|
||||
}
|
||||
|
||||
// src/validators/validateDns.ts
|
||||
function validateDNS(value) {
|
||||
if (!value) {
|
||||
return { valid: false, message: "DNS server address cannot be empty" };
|
||||
}
|
||||
if (validateIPV4(value).valid) {
|
||||
return { valid: true, message: "Valid" };
|
||||
}
|
||||
if (validateDomain(value).valid) {
|
||||
return { valid: true, message: "Valid" };
|
||||
}
|
||||
return {
|
||||
valid: false,
|
||||
message: "Invalid DNS server format. Examples: 8.8.8.8 or dns.example.com or dns.example.com/nicedns for DoH"
|
||||
};
|
||||
}
|
||||
|
||||
// src/validators/validateUrl.ts
|
||||
function validateUrl(url, protocols = ["http:", "https:"]) {
|
||||
try {
|
||||
const parsedUrl = new URL(url);
|
||||
if (!protocols.includes(parsedUrl.protocol)) {
|
||||
return {
|
||||
valid: false,
|
||||
message: `URL must use one of the following protocols: ${protocols.join(", ")}`
|
||||
};
|
||||
}
|
||||
return { valid: true, message: "Valid" };
|
||||
} catch (e) {
|
||||
return { valid: false, message: "Invalid URL format" };
|
||||
}
|
||||
}
|
||||
return baseclass.extend({
|
||||
validateDNS,
|
||||
validateDomain,
|
||||
validateIPV4,
|
||||
validateUrl
|
||||
});
|
||||
Reference in New Issue
Block a user