From eda30f23c4f0f5b73760b05d984afb10af3812bb Mon Sep 17 00:00:00 2001 From: mbaharip <62494292+mbahArip@users.noreply.github.com> Date: Thu, 9 May 2024 06:44:45 +0700 Subject: [PATCH] Add math equation parse from config --- src/utils/parseConfigFile.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/utils/parseConfigFile.ts b/src/utils/parseConfigFile.ts index cd80d6f..6d5906e 100644 --- a/src/utils/parseConfigFile.ts +++ b/src/utils/parseConfigFile.ts @@ -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()