Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable multi variable expansion + tests #2495

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading