Sha256: fb45ef2d072d7966e1bccff24c5bf0e570c41c36849266f7b67527c52fdb3711

Contents?: true

Size: 566 Bytes

Versions: 13

Compression:

Stored size: 566 Bytes

Contents

module PactBroker
  module Webhooks
    class CheckHostWhitelist

      def self.call(host, whitelist = PactBroker.configuration.webhook_host_whitelist)
        whitelist.select{ | whitelist_host | match?(host, whitelist_host) }
      end

      def self.match?(host, whitelist_host)
        if whitelist_host.is_a?(Regexp)
          host =~ whitelist_host
        else
          begin
            IPAddr.new(whitelist_host) === IPAddr.new(host)
          rescue IPAddr::Error
            host == whitelist_host
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pact_broker-2.27.0 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.26.1 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.26.0 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.25.0 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.24.0 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.23.4 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.23.3 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.23.2 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.23.1 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.23.0 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.22.0 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.21.0 lib/pact_broker/webhooks/check_host_whitelist.rb
pact_broker-2.20.0 lib/pact_broker/webhooks/check_host_whitelist.rb