Skip to content

Commit

Permalink
refactor: use .ReplaceAll
Browse files Browse the repository at this point in the history
  • Loading branch information
wass3r committed Jun 11, 2022
1 parent a7b0f37 commit adcc75c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions handlers/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion remote/discord/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions remote/slack/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -92,7 +92,7 @@ func sanitizeContents(b []byte) (string, error) {
return "", err
}

contents = strings.Replace(contents, `\/`, `/`, -1)
contents = strings.ReplaceAll(contents, `\/`, `/`)

return contents, nil
}

0 comments on commit adcc75c

Please sign in to comment.