Module: PwnedCheck
- Defined in:
- lib/pwnedcheck.rb
Overview
PwnedCheck module
Defined Under Namespace
Classes: InvalidEmail
Class Method Summary collapse
-
.check(item) ⇒ Array
Check an address against haveibeenpwned.com.
Class Method Details
.check(item) ⇒ Array
Check an address against haveibeenpwned.com
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pwnedcheck.rb', line 41 def self.check(item) uri = URI.parse "https://haveibeenpwned.com/api/breachedaccount/#{CGI::escape(item)}" response = Net::HTTP.get_response uri case response.code when '200' JSON.parse response.body when '404' [] when '400' fail InvalidEmail end end |