Skip to content

Commit

Permalink
Update event_controllers.go
Browse files Browse the repository at this point in the history
1. update the url.ParseRequestURI(image)
2. sperate the url error with image type error
  • Loading branch information
HuangruiChu committed Nov 1, 2023
1 parent 5735dfd commit 1e1ab4a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions event_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ func CreateEventController(w http.ResponseWriter, r *http.Request){
//Get the image URL
image := r.FormValue("image")
// Check if the image is valid
_, err := url.ParseRequestURI(image)
if err != nil || !isValidImageURL(image){
_, iamgeerr := url.ParseRequestURI(image)
if iamgeerr != nil {
Errors += "Invalid image URL! "
}

if !isValidImageURL(image){
Errors += "Image should have file types of \".png\", \".jpg\", \".jpeg\", \".gif\", or \".gifv\". "
}
//Get the location
location := r.FormValue("location")
// Check if the location is valid [TODO]
Expand Down

0 comments on commit 1e1ab4a

Please sign in to comment.