From c35e2fdd9a1f5bf2a611414783e8576d27ae6d03 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 18 May 2021 17:45:07 +0200 Subject: [PATCH] fix: do not use optional (nil) inputs for dynamic scope --- handler.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/handler.go b/handler.go index a4a3af1..87ce076 100644 --- a/handler.go +++ b/handler.go @@ -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) } } }