Skip to content

Commit

Permalink
trim whitespace?
Browse files Browse the repository at this point in the history
  • Loading branch information
arunk140 committed Jun 30, 2023
1 parent e238dde commit 89cb4de
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ func handlePostRequest(w http.ResponseWriter, r *http.Request) {
return
}

// trim whitespace
jsonBody.Text = strings.TrimSpace(jsonBody.Text)
if jsonBody.Text == "" {
http.Error(w, "Error parsing json - text", http.StatusBadRequest)
return
Expand Down Expand Up @@ -178,6 +180,8 @@ func handleGetRequest(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)

inputText := r.URL.Query().Get("text")
// trim whitespace
inputText = strings.TrimSpace(inputText)
if inputText == "" {
http.Error(w, "Missing Text Parameter.", http.StatusBadRequest)
}
Expand Down

0 comments on commit 89cb4de

Please sign in to comment.