fix panic due to direct request on /

This commit is contained in:
Benny~ 2020-02-09 18:06:25 +08:00
parent c0eabe3bc1
commit 4213dff391
No known key found for this signature in database
GPG Key ID: 7B84C5D3219A9B31

View File

@ -74,7 +74,14 @@ func main() {
IMG_PATH := c.Path()
// jpg
IMG_EXT := strings.Split(path.Ext(IMG_PATH), ".")[1]
seps := strings.Split(path.Ext(IMG_PATH), ".")
var IMG_EXT string
if len(seps) >= 2 {
IMG_EXT = seps[1]
} else {
c.Send("Invalid request")
return
}
// tsuki.jpg
IMG_NAME := path.Base(IMG_PATH)