From adcc75cc086089634abc5327a52f28b5b01d35d0 Mon Sep 17 00:00:00 2001 From: wass3r Date: Fri, 10 Jun 2022 23:38:06 -0500 Subject: [PATCH] refactor: use .ReplaceAll --- handlers/http.go | 6 +++--- remote/discord/util.go | 2 +- remote/slack/util.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/handlers/http.go b/handlers/http.go index 14d7542e..696bac04 100644 --- a/handlers/http.go +++ b/handlers/http.go @@ -43,7 +43,7 @@ func HTTPReq(args models.Action, msg *models.Message) (*models.HTTPResponse, err // TODO: refactor querydata // this is a temp fix for scenarios where // substitution above may have introduced spaces in the URL - url = strings.Replace(url, " ", "%20", -1) + url = strings.ReplaceAll(url, " ", "%20") url, payload, err := prepRequestData(url, args.Type, args.QueryData, msg) if err != nil { @@ -158,8 +158,8 @@ func createGetQuery(data map[string]any, msg *models.Message) (string, error) { u.Add(k, subv) } - encoded := u.Encode() // uses QueryEscape - encoded = strings.Replace(encoded, "+", "%20", -1) // replacing + with more reliable %20 + encoded := u.Encode() // uses QueryEscape + encoded = strings.ReplaceAll(encoded, "+", "%20") // replacing + with more reliable %20 return encoded, nil } diff --git a/remote/discord/util.go b/remote/discord/util.go index de6acb6b..01f34420 100644 --- a/remote/discord/util.go +++ b/remote/discord/util.go @@ -35,7 +35,7 @@ func removeBotMention(contents, botID string) (string, bool) { wasMentioned := false if strings.HasPrefix(contents, mention) { - contents = strings.Replace(contents, mention, "", -1) + contents = strings.ReplaceAll(contents, mention, "") contents = strings.TrimSpace(contents) wasMentioned = true } diff --git a/remote/slack/util.go b/remote/slack/util.go index 87f0c304..5196fb60 100644 --- a/remote/slack/util.go +++ b/remote/slack/util.go @@ -74,7 +74,7 @@ func removeBotMention(contents, botID string) (string, bool) { wasMentioned := false if strings.HasPrefix(contents, mention) { - contents = strings.Replace(contents, mention, "", -1) + contents = strings.ReplaceAll(contents, mention, "") contents = strings.TrimSpace(contents) wasMentioned = true } @@ -92,7 +92,7 @@ func sanitizeContents(b []byte) (string, error) { return "", err } - contents = strings.Replace(contents, `\/`, `/`, -1) + contents = strings.ReplaceAll(contents, `\/`, `/`) return contents, nil }