Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 13 additions & 25 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,38 +202,26 @@ func ParseMessage(raw string) (m *Message) {
return m
}

// Skip space after command
j++

// Find prefix for trailer
i = indexByte(raw[j:], prefix)

if i < 0 || raw[j+i-1] != space {

// There is no trailing argument!
m.Params = strings.Split(raw[j:], string(space))

// We're done here!
return m
i = strings.Index(raw[j:], " :")
if i >= 0 {
i += j
m.Trailing = raw[i+2:]

// We need to re-encode the trailing argument even if it was empty.
if len(m.Trailing) <= 0 {
m.EmptyTrailing = true
}
} else {
i = len(raw)
}

// Compensate for index on substring
i = i + j

// Check if we need to parse arguments.
// Parse Parameters
if i > j {
m.Params = strings.Split(raw[j:i-1], string(space))
}

m.Trailing = raw[i+1:]

// We need to re-encode the trailing argument even if it was empty.
if len(m.Trailing) <= 0 {
m.EmptyTrailing = true
m.Params = strings.Split(strings.Trim(raw[j:i], " "), string(space))
}

return m

}

// Len calculates the length of the string representation of this message.
Expand Down