Sha256: 23e9809a5e43f00ca2aabd9be5630c87a90e3a63620c3eb455fc9e0937992b43

Contents?: true

Size: 1.23 KB

Versions: 34

Compression:

Stored size: 1.23 KB

Contents

# ValidTenancyUrls will lookup configuration hash and
# deal with invalid urls. Its used by routing to constrain
# multi tenancy controllers
# SAAS: File related to SAAS with Custom Domains functionality

# TODO: Write Tests (PN)
module IuguSDK
  class ValidTenancyUrls

    # +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
    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

  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
iugusdk-1.0.11 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.10 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.9 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.8 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.7 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.6 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.5 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.4 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.3 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.2 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.1 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.0.alpha.32 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.0.alpha.31 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.0.alpha.30 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.0.alpha.29 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.0.alpha.28 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.0.alpha.27 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.0.alpha.26 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.0.alpha.25 lib/iugusdk/valid_tenancy_urls.rb
iugusdk-1.0.0.alpha.24 lib/iugusdk/valid_tenancy_urls.rb