Skip to content

Commit d02eed9

Browse files
authored
player/player.go: ExecuteCommand: use strings.CutPrefix to make sure the command starts with "/". (#988)
* player/player.go: add empty string check in command resolution. * fix: player/player.go: use strings.CutPrefix.
1 parent 16b0d3e commit d02eed9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server/player/player.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,16 @@ func (p *Player) ExecuteCommand(commandLine string) {
330330
return
331331
}
332332
args := strings.Split(commandLine, " ")
333-
command, ok := cmd.ByAlias(args[0][1:])
333+
334+
name, ok := strings.CutPrefix(args[0], "/")
335+
if !ok {
336+
return
337+
}
338+
339+
command, ok := cmd.ByAlias(name)
334340
if !ok {
335341
o := &cmd.Output{}
336-
o.Errort(cmd.MessageUnknown, args[0])
342+
o.Errort(cmd.MessageUnknown, name)
337343
p.SendCommandOutput(o)
338344
return
339345
}

0 commit comments

Comments
 (0)