File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,10 +70,12 @@ func WrapExpr(raw string) string {
7070}
7171
7272// UnwrapExpr strips the ${{ }} wrapper, returning the inner expression.
73+ // Tolerates varying whitespace inside the delimiters.
7374func UnwrapExpr (expr string ) string {
74- s := strings .TrimPrefix (expr , "${{ " )
75- s = strings .TrimSuffix (s , " }}" )
76- return s
75+ s := strings .TrimSpace (expr )
76+ s = strings .TrimPrefix (s , "${{" )
77+ s = strings .TrimSuffix (s , "}}" )
78+ return strings .TrimSpace (s )
7779}
7880
7981// NegateExpr prefixes a raw (unwrapped) expression with the not operator.
Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ func TestUnwrapExpr(t *testing.T) {
8383 assert .Equal (t , `flow.name == "prod"` , result )
8484}
8585
86+ func TestUnwrapExpr_NoInnerSpaces (t * testing.T ) {
87+ result := UnwrapExpr (`${{flow.name == "prod"}}` )
88+ assert .Equal (t , `flow.name == "prod"` , result )
89+ }
90+
8691func TestUnwrapExpr_AlreadyRaw (t * testing.T ) {
8792 result := UnwrapExpr (`flow.name == "prod"` )
8893 assert .Equal (t , `flow.name == "prod"` , result )
You can’t perform that action at this time.
0 commit comments