Skip to content

Commit

Permalink
refactor(api): replace invalid variable with empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
djabarovgeorge committed Dec 16, 2024
1 parent ef47067 commit 48f5434
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,12 @@ export class GeneratePreviewUsecase {
let controlValuesString = JSON.stringify(controlValues);

for (const invalidVariable of invalidVariables) {
if (!controlValuesString.includes(invalidVariable.name)) {
if (!controlValuesString.includes(invalidVariable.template)) {
continue;
}

const invalidVariableExpression = invalidVariable.template.replace('{{', '').replace('}}', '');
const liquidJsParsableString = PREVIEW_ERROR_MESSAGE_PLACEHOLDER.replace(
INVALID_VARIABLE_PLACEHOLDER,
invalidVariableExpression
);
controlValuesString = replaceAll(controlValuesString, invalidVariable.template, liquidJsParsableString);
const EMPTY_STRING = '';
controlValuesString = replaceAll(controlValuesString, invalidVariable.template, EMPTY_STRING);
}

return JSON.parse(controlValuesString) as Record<string, unknown>;
Expand Down

0 comments on commit 48f5434

Please sign in to comment.