Moved unflatten to site.js, implemented Admin.cshtml view

This commit is contained in:
2025-11-15 11:02:31 +01:00
parent b46b9ffb8e
commit 2df6111bd1
4 changed files with 317 additions and 30 deletions

View File

@@ -239,4 +239,30 @@ function validatePassword(password) {
const strongPasswordRegex =
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_\-+=\[{\]};:'",<.>/?\\|`~]).{8,}$/;
return strongPasswordRegex.test(password);
}
}
function unflatten(obj) {
const result = {};
for (const [key, value] of Object.entries(obj)) {
const parts = key.split(".");
let current = result;
for (let i = 0; i < parts.length; i++) {
const part = parts[i];
if (i === parts.length - 1) {
if (typeof value === "string" && /^[\[{]/.test(value.trim())) {
try {
current[part] = JSON.parse(value);
} catch {
current[part] = value;
}
} else {
current[part] = value;
}
} else {
current[part] = current[part] || {};
current = current[part];
}
}
}
return result;
}