mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
feat: Refactor the code in helpers.lua to use escaped settings and server names for matching multiple settings. This ensures that the correct values are assigned to the corresponding variables.
This commit is contained in:
parent
519d1cc818
commit
f09db9e9dd
1 changed files with 5 additions and 2 deletions
|
|
@ -263,18 +263,21 @@ function helpers.load_variables(all_variables, plugins)
|
|||
end
|
||||
end
|
||||
for setting, data in pairs(all_settings) do
|
||||
local escaped_setting = setting:gsub("([^%w])", "%%%1")
|
||||
if all_variables[setting] then
|
||||
variables["global"][setting] = all_variables[setting]
|
||||
end
|
||||
if data.multiple then
|
||||
for variable, value in pairs(all_variables) do
|
||||
local multiple_setting = variable:match("^(" .. setting .. "_%d+)$")
|
||||
local multiple_setting = variable:match("^(" .. escaped_setting .. "_%d+)$")
|
||||
if multiple_setting then
|
||||
variables["global"][multiple_setting] = value
|
||||
end
|
||||
if multisite then
|
||||
for _, server_name in ipairs(server_names) do
|
||||
multiple_setting = variable:match("^" .. server_name .. "_(" .. setting .. "_%d+)$")
|
||||
local escaped_server_name = server_name:gsub("([^%w])", "%%%1")
|
||||
multiple_setting =
|
||||
variable:match("^" .. escaped_server_name .. "_(" .. escaped_setting .. "_%d+)$")
|
||||
if multiple_setting then
|
||||
variables[server_name][multiple_setting] = value
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue