Sha256: b2033b9d6abbb28df4037ef6561150cd12fb969d38d7842f8b558d5a26be8878

Contents?: true

Size: 582 Bytes

Versions: 8

Compression:

Stored size: 582 Bytes

Contents

module Pageflow
  # Use as {Configuration#public_entry_redirect} to make sure entries
  # are accessed via their account's configured cname.
  #
  # @since 12.4
  class PrimaryDomainEntryRedirect
    def call(entry, request)
      site = entry.site

      if site.cname.present? &&
         !known_domains(site).include?(request.host)
        [request.protocol, site.cname, request.fullpath].join
      end
    end

    private

    def known_domains(site)
      [
        site.cname,
        (site.additional_cnames || '').split(',').map(&:strip)
      ].flatten
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pageflow-17.0.4 lib/pageflow/primary_domain_entry_redirect.rb
pageflow-17.0.3 lib/pageflow/primary_domain_entry_redirect.rb
pageflow-17.0.2 lib/pageflow/primary_domain_entry_redirect.rb
pageflow-17.0.1 lib/pageflow/primary_domain_entry_redirect.rb
pageflow-17.0.0 lib/pageflow/primary_domain_entry_redirect.rb
pageflow-16.2.0 lib/pageflow/primary_domain_entry_redirect.rb
pageflow-16.1.0 lib/pageflow/primary_domain_entry_redirect.rb
pageflow-16.0.0 lib/pageflow/primary_domain_entry_redirect.rb