Do not redirect if no originURI is set
This commit is contained in:
		
							parent
							
								
									477643b58e
								
							
						
					
					
						commit
						66d5aae498
					
				| 
						 | 
					@ -297,6 +297,7 @@ func SendMail(httpResp http.ResponseWriter, httpReq *http.Request) {
 | 
				
			||||||
		contactResponse.Message = "Invalid request, please review your input and try again."
 | 
							contactResponse.Message = "Invalid request, please review your input and try again."
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if contactRequest.OriginURI != "" {
 | 
				
			||||||
		originURL, err := url.Parse(contactRequest.OriginURI)
 | 
							originURL, err := url.Parse(contactRequest.OriginURI)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			log.Printf("error parsing the origin URL %s (%s)", originURL, err.Error())
 | 
								log.Printf("error parsing the origin URL %s (%s)", originURL, err.Error())
 | 
				
			||||||
| 
						 | 
					@ -308,10 +309,14 @@ func SendMail(httpResp http.ResponseWriter, httpReq *http.Request) {
 | 
				
			||||||
		q.Set("message", contactResponse.Message)
 | 
							q.Set("message", contactResponse.Message)
 | 
				
			||||||
		originURL.RawQuery = q.Encode()
 | 
							originURL.RawQuery = q.Encode()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	respRawData, _ := json.Marshal(contactResponse)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		httpResp.Header().Set("Location", originURL.String())
 | 
							httpResp.Header().Set("Location", originURL.String())
 | 
				
			||||||
		httpResp.WriteHeader(http.StatusSeeOther)
 | 
							httpResp.WriteHeader(http.StatusSeeOther)
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							httpResp.WriteHeader(http.StatusOK)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						respRawData, _ := json.Marshal(contactResponse)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	httpResp.Header().Set("Content-Type", "application/json; charset=UTF-8")
 | 
						httpResp.Header().Set("Content-Type", "application/json; charset=UTF-8")
 | 
				
			||||||
	httpResp.Write(respRawData)
 | 
						httpResp.Write(respRawData)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in New Issue