fix: do not use optional (nil) inputs for dynamic scope
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
xdrm-brackets 2021-05-18 17:45:07 +02:00
parent 8c2ebd916e
commit c35e2fdd9a
No known key found for this signature in database
GPG Key ID: 99F952DD5DE2439E
1 changed files with 7 additions and 4 deletions

View File

@ -59,11 +59,14 @@ func (s Handler) resolve(w http.ResponseWriter, r *http.Request) {
for b, perm := range list {
scope[a][b] = perm
for name, value := range input.Data {
scope[a][b] = strings.ReplaceAll(
scope[a][b],
fmt.Sprintf("[%s]", name),
fmt.Sprintf("[%v]", value),
var (
token = fmt.Sprintf("[%s]", name)
replacement = ""
)
if value != nil {
replacement = fmt.Sprintf("[%v]", value)
}
scope[a][b] = strings.ReplaceAll(scope[a][b], token, replacement)
}
}
}