Skip to content

Commit

Permalink
force country to be 2 letters
Browse files Browse the repository at this point in the history
  • Loading branch information
zifnab06 committed Feb 6, 2024
1 parent fe17279 commit cba3f53
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ func main() {
return
}

if len(stat.Country) != 2 {
w.WriteHeader(http.StatusBadRequest)
w.Header().Add("Content-Type", "text/plain")
w.Write([]byte("country must be a two letter iso code"))
return
}

if stat.Country != "Unknown" {
stat.Country = strings.ToUpper(stat.Country)
}
Expand Down

0 comments on commit cba3f53

Please sign in to comment.