Skip to content

Commit 956a0ea

Browse files
committed
testing changes
1 parent 44e89a2 commit 956a0ea

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

internals/proxy/proxy.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,18 @@ func templateJSON(data map[string]interface{}, variables map[string]interface{})
8787
str, ok := v.(string)
8888

8989
if ok {
90-
re, err := regexp.Compile(`{{\s*\.([A-Za-z_][A-Za-z0-9_]*)}}\s*`)
90+
re, err := regexp.Compile(`{{\s*\.([A-Za-z_][A-Za-z0-9_]*)\s*}}`)
9191

9292
if err != nil {
9393
log.Error("Encountered Error while Compiling Regex: ", err.Error())
9494
}
9595

96-
matches := re.FindAllString(str, -1)
96+
matches := re.FindAllStringSubmatch(str, -1)
9797

9898
if len(matches) > 1 {
99-
for _, tmplStr := range(matches) {
100-
tmplKey := tmplStr[3 : len(tmplStr)-2]
99+
for i, tmplStr := range(matches) {
100+
101+
tmplKey := matches[i][1]
101102

102103
variable, err := json.Marshal(variables[tmplKey])
103104

@@ -106,10 +107,10 @@ func templateJSON(data map[string]interface{}, variables map[string]interface{})
106107
break
107108
}
108109

109-
data[k] = strings.ReplaceAll(str, string(variable), tmplStr)
110+
data[k] = strings.ReplaceAll(str, string(variable), tmplStr[0])
110111
}
111112
} else {
112-
tmplKey := matches[0][3 : len(matches[0])-2]
113+
tmplKey := matches[0][1]
113114

114115
data[k] = variables[tmplKey]
115116
}

0 commit comments

Comments
 (0)