Skip to content

Commit

Permalink
Improve Args payload parsing
Browse files Browse the repository at this point in the history
This us achieved by using strings.Fields instead of strings.Split

This results in a cleaner output when parsing messages like "/tags a          lot         of        spaces"

Output before: `[]string{"a", "", "", "", "", "", "", "", "", "", "lot", "", "", "", "", "", "", "", "", "of", "", "", "", "", "", "", "", "spaces"}`

Output after the change: `[]string{"a", "lot", "of", "spaces"}`
  • Loading branch information
70sh1 authored and demget committed Feb 25, 2024
1 parent 59775c2 commit 06bef0a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func (c *nativeContext) Args() []string {
case c.u.Message != nil:
payload := strings.Trim(c.u.Message.Payload, " ")
if payload != "" {
return strings.Split(payload, " ")
return strings.Fields(payload)
}
case c.u.Callback != nil:
return strings.Split(c.u.Callback.Data, "|")
Expand Down

0 comments on commit 06bef0a

Please sign in to comment.