Skip to content

Commit

Permalink
enable multi variable expansion + tests (#2495)
Browse files Browse the repository at this point in the history
* enable multi var parsing + tests

* formatting violation fix
  • Loading branch information
divmeh-aws authored Jan 7, 2025
1 parent 6c12b9f commit b792363
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static ObjectNode expandNode(Node node) {
*/
private static final class VariableExpander extends NodeVisitor.Default<Node> {

private static final Pattern INLINE = Pattern.compile("(?:^|[^\\\\])\\$\\{(.+)}");
private static final Pattern INLINE = Pattern.compile("(?:^|[^\\\\])\\$\\{([^}]+)}");
private static final Pattern ESCAPED_INLINE = Pattern.compile("\\\\\\$");

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ public void expandsEnvironmentVariables() {
// Did the array and string values in it expand?
assertThat(transform.getArgs(),
equalTo(Node.objectNode()
.withMember("tags", Node.fromStrings("Hi", "compoundTagFromEnv", "${BAZ}"))));
.withMember("tags",
Node.fromStrings("Hi", "compoundTagFromEnv", "HiAndTagFromEnv", "${BAZ}"))));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"tags": [
"${FOO}",
"compound${BAR}",
"${FOO}And${BAR}",
"\\${BAZ}"
]
}
Expand Down

0 comments on commit b792363

Please sign in to comment.