From 920f3ef3f92f4bf7777e3e45ebf04ae606e1b760 Mon Sep 17 00:00:00 2001 From: Zaccary Price Date: Thu, 22 Feb 2024 16:04:58 +0000 Subject: [PATCH] allow whitespace in env var replacement will allow adding env var placeholders such as `{{ HOMEPAGE_VAR_FOO }}`, with surrounding whitespace. something that had caught me out when attempting to configure this myself. --- src/utils/config/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/config/config.js b/src/utils/config/config.js index 18dedf62..eb2dc1ee 100644 --- a/src/utils/config/config.js +++ b/src/utils/config/config.js @@ -59,11 +59,11 @@ export function substituteEnvironmentVars(str) { const cachedVars = getCachedEnvironmentVars(); cachedVars.forEach(([key, value]) => { if (key.startsWith(homepageVarPrefix)) { - result = result.replaceAll(`{{${key}}}`, value); + result = result.replaceAll(new RegExp(`{{\\s*${key}\\s*}}`, "g"), value); } else if (key.startsWith(homepageFilePrefix)) { const filename = value; const fileContents = readFileSync(filename, "utf8"); - result = result.replaceAll(`{{${key}}}`, fileContents); + result = result.replaceAll(new RegExp(`{{\\s*${key}\\s*}}`, "g"), fileContents); } }); }