Skip to content

Commit

Permalink
Fix order of substitutions to ensure dataset name is resolved first (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgaldi authored Oct 27, 2023
1 parent e0e543d commit 6a88ce4
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,18 @@ private static String wrapContentWithAutoResponse(String content) {
}

private static String createAccessRequestEmailBody(String bodyTemplate, Map<String, String> templateSubs, String datasetName) {
String bodyWithFilledOutFormFields = templateSubs.entrySet().stream().reduce(
bodyTemplate,
String bodyWithDatasetName = bodyTemplate.replaceAll(
"\\$\\$DATASET_NAME\\$\\$",
escapeHtml(datasetName)
);

return templateSubs.entrySet().stream().reduce(
bodyWithDatasetName,
(body, entry) -> body.replaceAll(
"\\$\\$" + entry.getKey().toUpperCase() + "\\$\\$",
escapeHtml(entry.getValue())
),
String::concat
);

return bodyWithFilledOutFormFields.replaceAll(
"\\$\\$DATASET_NAME\\$\\$",
escapeHtml(datasetName)
);
}
}

0 comments on commit 6a88ce4

Please sign in to comment.