Skip to content

Commit

Permalink
changed regex to expect a trimmed input
Browse files Browse the repository at this point in the history
  • Loading branch information
pazhersh committed May 22, 2024
1 parent 60b7488 commit 116ecb6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ const renderRecursively = (inputJson, template, execOptions = {}) => {
return Object.fromEntries(
Object.entries(template).flatMap(([key, value]) => {
const SPREAD_KEYWORD = "spreadValue";
const keywordMatcher = `^\\s*\\{\\{\\s*${SPREAD_KEYWORD}\\(\\s*\\)\\s*\\}\\}\\s*$`; // matches {{ <Keyword>() }} with white spaces where you'd expect them
const keywordMatcher = `^\\{\\{\\s*${SPREAD_KEYWORD}\\(\\s*\\)\\s*\\}\\}$`; // matches {{ <Keyword>() }} with white spaces where you'd expect them

if (key.match(keywordMatcher)) {
if (key.trim().match(keywordMatcher)) {
const evaluatedValue = renderRecursively(inputJson, value, execOptions);
if (typeof evaluatedValue !== "object") {
throw new Error(
Expand Down

0 comments on commit 116ecb6

Please sign in to comment.