fix index out of range bug.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
91ae3a4c55
commit
42457f46db
@ -141,7 +141,7 @@ func parseTo(to []string, authorEmail string, matchEmail bool) []int64 {
|
||||
var ids []int64
|
||||
attachEmail := true
|
||||
|
||||
for _, value := range to {
|
||||
for _, value := range trimElement(to) {
|
||||
idArray := trimElement(strings.Split(value, ":"))
|
||||
|
||||
// check id
|
||||
|
@ -146,6 +146,10 @@ func TestParseTo(t *testing.T) {
|
||||
|
||||
ids = parseTo(input, "a@gmail.com", true)
|
||||
assert.Equal(t, []int64{0, 4, 5}, ids)
|
||||
|
||||
// test empty ids
|
||||
ids = parseTo([]string{"", " ", " "}, "a@gmail.com", true)
|
||||
assert.Equal(t, 0, len(ids))
|
||||
}
|
||||
|
||||
func TestCheckFileExist(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user