diff --git a/fe-app-podkop/src/helpers/index.ts b/fe-app-podkop/src/helpers/index.ts index b3fe842..053e45e 100644 --- a/fe-app-podkop/src/helpers/index.ts +++ b/fe-app-podkop/src/helpers/index.ts @@ -1 +1,2 @@ export * from './getBaseUrl'; +export * from './parseValueList'; diff --git a/fe-app-podkop/src/helpers/parseValueList.ts b/fe-app-podkop/src/helpers/parseValueList.ts new file mode 100644 index 0000000..78d0b93 --- /dev/null +++ b/fe-app-podkop/src/helpers/parseValueList.ts @@ -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 +} diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js index 1e5db3c..3586973 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js @@ -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,