feat: implement parseValueList helper

This commit is contained in:
divocat
2025-10-03 02:01:06 +03:00
parent 260b7b9558
commit 327c3d2b68
3 changed files with 16 additions and 0 deletions

View File

@@ -1 +1,2 @@
export * from './getBaseUrl';
export * from './parseValueList';

View File

@@ -0,0 +1,9 @@
export function parseValueList(value: string): string[] {
return value
.split(/\n/) // Split to array by newline separator
.map((line) => line.split('//')[0]) // Remove comments
.join(' ') // Build clean string
.split(/[,\s]+/) // Split to array by comma and space
.map((s) => s.trim()) // Remove extra spaces
.filter(Boolean); // Leave nonempty items
}

View File

@@ -233,6 +233,11 @@ function getBaseUrl() {
const { protocol, hostname } = window.location;
return `${protocol}//${hostname}`;
}
// src/helpers/parseValueList.ts
function parseValueList(value) {
return value.split(/\n/).map((line) => line.split("//")[0]).join(" ").split(/[,\s]+/).map((s) => s.trim()).filter(Boolean);
}
return baseclass.extend({
ALLOWED_WITH_RUSSIA_INSIDE,
BOOTSTRAP_DNS_SERVER_OPTIONS,
@@ -253,6 +258,7 @@ return baseclass.extend({
UPDATE_INTERVAL_OPTIONS,
bulkValidate,
getBaseUrl,
parseValueList,
validateDNS,
validateDomain,
validateIPV4,