Skip to content

Commit

Permalink
Allow extra spaces between commands (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
larkox authored Jul 1, 2020
1 parent bcb8a56 commit 889ce94
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"regexp"
"strings"

"github.com/mattermost/mattermost-server/v5/model"
Expand Down Expand Up @@ -69,7 +70,9 @@ func (p *Plugin) postCommandResponse(args *model.CommandArgs, text string) {

// ExecuteCommand executes a given command and returns a command response.
func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
stringArgs := strings.Split(strings.TrimSpace(args.Command), " ")
spaceRegExp := regexp.MustCompile(`\s+`)
trimmedArgs := spaceRegExp.ReplaceAllString(strings.TrimSpace(args.Command), " ")
stringArgs := strings.Split(trimmedArgs, " ")
lengthOfArgs := len(stringArgs)
restOfArgs := []string{}

Expand Down

0 comments on commit 889ce94

Please sign in to comment.