Sha256: 49c6d287d62c9f8d22c4897ff1390678fc36e78ba24c61886fa7cd7de0f7011e

Contents?: true

Size: 733 Bytes

Versions: 1

Compression:

Stored size: 733 Bytes

Contents

require 'httparty'


module Moocher
  module Domain
    def domain_blacklisted?(domain_name, details: false)
      return "Domain doesn't seem to be valid." if (domain_name =~ /^((http|https):\/\/)?[a-z0-9]*(\.?[a-z0-9]+)\.[a-z]{2,5}(:[0-9]{1,5})?(\/.)?$/ix).nil?
      base_url = 'https://api.moocher.io/baddomain/'
      unless details
        response = HTTParty.get(base_url + domain_name)
        response.success?
      else
        if details == true
          response = HTTParty.get("https://api.moocher.io/baddomain/#{domain_name}", headers: {"Content-Type": "application/json"})
          return response.parsed_response
        else
          "'details:' can only be set to true."
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
moocher-0.1.1.3pre lib/moocher/domains.rb