Sha256: e3e4be045585b253a9cf59fff763bea9e05031195888851cd0f9fb7c5b7f0b43

Contents?: true

Size: 786 Bytes

Versions: 4

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

module  Drillbit
module  Matchers
class   Subdomain
  attr_accessor :allowed_api_subdomains,
                :allowed_subdomains,
                :request

  def initialize(allowed_subdomains:     Drillbit.configuration.allowed_subdomains,
                 allowed_api_subdomains: Drillbit.configuration.allowed_api_subdomains)

    self.allowed_subdomains     = Array(allowed_subdomains)
    self.allowed_api_subdomains = Array(allowed_api_subdomains)
  end

  def matches?(request)
    self.request = Requests::Base.resolve(request)

    allowed_subdomains.include? request.subdomain
  end

  def matches_api_subdomain?(request)
    self.request = Requests::Base.resolve(request)

    allowed_api_subdomains.include? request.subdomain
  end
end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
drillbit-3.0.3 lib/drillbit/matchers/subdomain.rb
drillbit-3.0.2 lib/drillbit/matchers/subdomain.rb
drillbit-3.0.1 lib/drillbit/matchers/subdomain.rb
drillbit-3.0.0 lib/drillbit/matchers/subdomain.rb