From fa174103b571b9a4c4f7b4993811cd99f376e1a6 Mon Sep 17 00:00:00 2001 From: Kartikay Date: Tue, 26 Dec 2023 20:48:51 +0530 Subject: [PATCH] Address comments Signed-off-by: Kartikay --- cmd/thanos/rule.go | 6 +++--- cmd/thanos/rule_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/thanos/rule.go b/cmd/thanos/rule.go index 4bbb6626695..27c0812cd49 100644 --- a/cmd/thanos/rule.go +++ b/cmd/thanos/rule.go @@ -7,7 +7,7 @@ import ( "bytes" "context" "fmt" - "html/template" + "text/template" "math/rand" "net/http" "net/url" @@ -936,10 +936,10 @@ func reloadRules(logger log.Logger, func tableLinkForExpression(tmpl string, expr string) (string, error) { // template example: "/graph?g0.expr={{.Expr}}&g0.tab=1" - escapedExpression := strings.ReplaceAll(url.QueryEscape(expr), "+", "%20") + escapedExpression := url.QueryEscape(expr) escapedExpr := Expression{Expr: escapedExpression} - t, err := template.New("url").Parse(tmpl) + t, err := template.New("name").Parse(tmpl) if err != nil { return "", errors.Wrap(err, "failed to parse template") } diff --git a/cmd/thanos/rule_test.go b/cmd/thanos/rule_test.go index 212135cf67e..097b66e65b8 100644 --- a/cmd/thanos/rule_test.go +++ b/cmd/thanos/rule_test.go @@ -89,7 +89,7 @@ func Test_tableLinkForExpression(t *testing.T) { { template: `/graph?g0.expr={{.Expr}}&g0.tab=1`, expr: `up{app="foo yoo"}`, - expectStr: `/graph?g0.expr=up%7Bapp%3D%22foo%20yoo%22%7D&g0.tab=1`, + expectStr: `/graph?g0.expr=up%7Bapp%3D%22foo+yoo%22%7D&g0.tab=1`, expectErr: false, }, {