Skip to content

Commit

Permalink
Fix naming of file (omit slash so it works)
Browse files Browse the repository at this point in the history
  • Loading branch information
SumiGovindaraju committed Jan 29, 2019
1 parent cc97d29 commit 1c2fbb2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mail_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ func (message *MailMessage) saveAttachments() error {

lastIndexOfSlash := strings.LastIndex(src, "/")
var fileName string
if lastIndexOfSlash != -1 {
fileName = fmt.Sprintf("%d_%s.jpg", i, src[lastIndexOfSlash:len(src)])
if lastIndexOfSlash != -1 && lastIndexOfSlash < len(src)-1 {
fileName = fmt.Sprintf("%d_%s.jpg", i, src[(lastIndexOfSlash+1):len(src)])
} else {
fileName = fmt.Sprintf("%d.jpg", i)
}
Expand Down

0 comments on commit 1c2fbb2

Please sign in to comment.