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.
This commit is contained in:
parent
577721bd75
commit
920f3ef3f9
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user