Prevent cache poisoning

Stephen Paul Weber created

Change summary

lib/geo_code_repo.rb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Detailed changes

lib/geo_code_repo.rb 🔗

@@ -16,7 +16,10 @@ class GeoCodeRepo
 				"https://geocoder.ca/",
 				tls: { verify_peer: true }
 			).aget(query: { json: 1, locate: q }).then { |res|
-				JSON.parse(res.response)
+				json = JSON.parse(res.response)
+				raise "Geocode Failure" unless json["latt"] && json["longt"]
+
+				json
 			}
 		}.then(&GeoCode.method(:for))
 	end