mirror of
https://github.com/infinition/Bjorn.git
synced 2025-12-06 06:11:46 +00:00
Fixes an issue with array based fields when saving from the web UI
This commit is contained in:
@@ -68,9 +68,18 @@ function generateConfigForm(config) {
|
||||
|
||||
const formData = new FormData(formElement);
|
||||
const formDataObj = {};
|
||||
|
||||
// Each of these fields contains an array of data. Lets track these so we can ensure the format remains an array for the underlying structure.
|
||||
const arrayFields = [
|
||||
"portlist",
|
||||
"mac_scan_blacklist",
|
||||
"ip_scan_blacklist",
|
||||
"steal_file_names",
|
||||
"steal_file_extensions",
|
||||
];
|
||||
|
||||
formData.forEach((value, key) => {
|
||||
if (value.includes(',')) {
|
||||
// Check if the input from the user contains a `,` character or is a known array field
|
||||
if (value.includes(',') || arrayFields.includes(key)) {
|
||||
formDataObj[key] = value.split(',').map(item => {
|
||||
const trimmedItem = item.trim();
|
||||
return isNaN(trimmedItem) ? trimmedItem : parseFloat(trimmedItem);
|
||||
|
||||
Reference in New Issue
Block a user