From c055d6a1ba1dc8c18f3b58fe6ca929766349b973 Mon Sep 17 00:00:00 2001 From: Christiaan Goossens <9487666+christiaangoossens@users.noreply.github.com> Date: Sat, 15 Jun 2024 13:50:06 +0200 Subject: [PATCH] Trim whitespace and quotes in variable substitution --- src/utils/config/config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/config/config.js b/src/utils/config/config.js index 18dedf62..b65c6b3d 100644 --- a/src/utils/config/config.js +++ b/src/utils/config/config.js @@ -59,7 +59,10 @@ export function substituteEnvironmentVars(str) { const cachedVars = getCachedEnvironmentVars(); cachedVars.forEach(([key, value]) => { if (key.startsWith(homepageVarPrefix)) { - result = result.replaceAll(`{{${key}}}`, value); + // Remove whitespace and quotes on edges of the string + // Leave quotes in the middle of the string in + const sanitizedValue = value.replace(/^[\s"']+|[\s"']+$/g, ''); + result = result.replaceAll(`{{${key}}}`, sanitizedValue); } else if (key.startsWith(homepageFilePrefix)) { const filename = value; const fileContents = readFileSync(filename, "utf8");