Skip to content

Commit 28005ac

Browse files
committed
Add test for png file to create event
Checks that the logo and logo square are png files, and throws an error if they are not. Fixes #108 Signed-off-by: Matt Stratton <[email protected]>
1 parent b2f7e80 commit 28005ac

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

event/event.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"log"
88
"os"
99
"path/filepath"
10+
"regexp"
1011
"strings"
1112

1213
"github.com/alecthomas/template"
@@ -115,6 +116,10 @@ var qsCreateEvent = []*survey.Question{
115116
if _, err := os.Stat(str); err != nil {
116117
return errors.New("File not found.")
117118
}
119+
ret, _ := regexp.MatchString(`[0-9a-z]+\.(png|PNG)`, str)
120+
if ret != true {
121+
return errors.New("Logo image must be a PNG file")
122+
}
118123
}
119124

120125
return nil
@@ -133,6 +138,10 @@ var qsCreateEvent = []*survey.Question{
133138
if _, err := os.Stat(str); err != nil {
134139
return errors.New("File not found.")
135140
}
141+
ret, _ := regexp.MatchString(`[0-9a-z]+\.(png|PNG)`, str)
142+
if ret != true {
143+
return errors.New("Logo image must be a PNG file")
144+
}
136145
}
137146

138147
return nil

0 commit comments

Comments
 (0)