mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-31 21:59:17 +03:00
feat: migrate validatePath to modular
This commit is contained in:
@@ -409,12 +409,18 @@ function createConfigSection(section, map, network) {
|
||||
o.rmempty = false;
|
||||
o.ucisection = s.section;
|
||||
o.validate = function (section_id, value) {
|
||||
if (!value || value.length === 0) return true;
|
||||
const pathRegex = /^\/[a-zA-Z0-9_\-\/\.]+$/;
|
||||
if (!pathRegex.test(value)) {
|
||||
return _('Invalid path format. Path must start with "/" and contain valid characters');
|
||||
// Optional
|
||||
if (!value || value.length === 0) {
|
||||
return true
|
||||
}
|
||||
return true;
|
||||
|
||||
const validation = main.validatePath(value);
|
||||
|
||||
if (validation.valid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return _(validation.message)
|
||||
};
|
||||
|
||||
o = s.taboption('basic', form.Flag, 'remote_domain_lists_enabled', _('Remote Domain Lists'), _('Download and use domain lists from remote URLs'));
|
||||
@@ -453,12 +459,18 @@ function createConfigSection(section, map, network) {
|
||||
o.rmempty = false;
|
||||
o.ucisection = s.section;
|
||||
o.validate = function (section_id, value) {
|
||||
if (!value || value.length === 0) return true;
|
||||
const pathRegex = /^\/[a-zA-Z0-9_\-\/\.]+$/;
|
||||
if (!pathRegex.test(value)) {
|
||||
return _('Invalid path format. Path must start with "/" and contain valid characters');
|
||||
// Optional
|
||||
if (!value || value.length === 0) {
|
||||
return true
|
||||
}
|
||||
return true;
|
||||
|
||||
const validation = main.validatePath(value);
|
||||
|
||||
if (validation.valid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return _(validation.message)
|
||||
};
|
||||
|
||||
o = s.taboption('basic', form.ListValue, 'user_subnet_list_type', _('User Subnet List Type'), _('Select how to add your custom subnets'));
|
||||
|
||||
@@ -59,6 +59,27 @@ function validateUrl(url, protocols = ["http:", "https:"]) {
|
||||
}
|
||||
}
|
||||
|
||||
// src/validators/validatePath.ts
|
||||
function validatePath(value) {
|
||||
if (!value) {
|
||||
return {
|
||||
valid: false,
|
||||
message: "Path cannot be empty"
|
||||
};
|
||||
}
|
||||
const pathRegex = /^\/[a-zA-Z0-9_\-/.]+$/;
|
||||
if (pathRegex.test(value)) {
|
||||
return {
|
||||
valid: true,
|
||||
message: "Valid"
|
||||
};
|
||||
}
|
||||
return {
|
||||
valid: false,
|
||||
message: 'Invalid path format. Path must start with "/" and contain valid characters'
|
||||
};
|
||||
}
|
||||
|
||||
// src/constants.ts
|
||||
var STATUS_COLORS = {
|
||||
SUCCESS: "#4caf50",
|
||||
@@ -67,7 +88,11 @@ var STATUS_COLORS = {
|
||||
};
|
||||
var FAKEIP_CHECK_DOMAIN = "fakeip.podkop.fyi";
|
||||
var IP_CHECK_DOMAIN = "ip.podkop.fyi";
|
||||
var REGIONAL_OPTIONS = ["russia_inside", "russia_outside", "ukraine_inside"];
|
||||
var REGIONAL_OPTIONS = [
|
||||
"russia_inside",
|
||||
"russia_outside",
|
||||
"ukraine_inside"
|
||||
];
|
||||
var ALLOWED_WITH_RUSSIA_INSIDE = [
|
||||
"russia_inside",
|
||||
"meta",
|
||||
@@ -174,5 +199,6 @@ return baseclass.extend({
|
||||
validateDNS,
|
||||
validateDomain,
|
||||
validateIPV4,
|
||||
validatePath,
|
||||
validateUrl
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user