Class: IuguSDK::ValidTenancyUrls

Inherits:
Object
  • Object
show all
Defined in:
lib/iugusdk/valid_tenancy_urls.rb

Class Method Summary collapse

Class Method Details

.matches?(request) ⇒ Boolean

matches? will check a request.host against a set of invalid urls

  • Args:

    • request -> An ActionDispatch::Request object

  • Success

    • Return true if request.host is found in the invalid array

  • False

    • Return true if request.host is not found in the invalid array

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/iugusdk/valid_tenancy_urls.rb', line 18

def self.matches?(request)
  application_domain = IuguSDK::application_main_host
  application_domain = application_domain.gsub('.dev','')
  invalids = [ application_domain, ['www.',application_domain].join ]
  invalids |= IuguSDK::custom_domain_invalid_prefixes.map { |prefix| [prefix,application_domain].join }
  invalids |= IuguSDK::custom_domain_invalid_hosts
  normalized_host = request.host.gsub('.dev','')
  unless Rails.env.production?
    return false if normalized_host.match("^#{application_domain}\.[^\.]+\.[^\.]+\.[^\.]+\.[^\.]+\.xip.io")
  end
  !invalids.include?( normalized_host )
end