Add math equation parse from config

This commit is contained in:
mbaharip
2024-05-09 06:44:45 +07:00
parent 93e125144b
commit eda30f23c4
+15 -1
View File
@@ -32,7 +32,21 @@ export function parseConfigFile(config: string):
.replace(/\t/g, "") // Remove line breaks and tabs
.replace(/basePath:(.*?),/g, 'basePath: "placeholder-domain",') // Replace basePath variable with placeholder
.replace(/maxFileSize:(.*?),/g, "maxFileSize: 4194304,") // Set maxFileSize to 4MB
.replace(/maxFileSize:(.*?),/g, (str) => {
if (!str) return "maxFileSize: 4194304,"; // Set maxFileSize to 4MB
const value = str.split(":")[1].split(",")[0].trim();
return `maxFileSize: ${eval(value)},`;
}) // Set maxFileSize to 4MB
.replace(/streamMaxSize:(.*?),/g, (str) => {
if (!str) return "streamMaxSize: 104857600,";
const value = str.split(":")[1].split(",")[0].trim();
return `streamMaxSize: ${eval(value)},`;
}) // Set streamMaxSize to 100MB
.replace(/temporaryTokenDuration:(.*?),/g, (str) => {
if (!str) return "temporaryTokenDuration: 6,";
const value = str.split(":")[1].split(",")[0].trim();
return `temporaryTokenDuration: ${eval(value)},`;
})
.replace(/([a-zA-Z]*?):\s/g, '"$1": ') // Add double quotes to keys
.trim()