Sha256: afdc2e27450a1d2d591bc7ae4a3325615902610406a271ded2da6d7dd75a22c0

Contents?: true

Size: 611 Bytes

Versions: 2

Compression:

Stored size: 611 Bytes

Contents

module Locomotive
  module Concerns
    module RedirectToMainHostController

      extend ActiveSupport::Concern

      included do

        before_action :redirect_to_main_host

      end

      private

      def redirect_to_main_host
        return if Locomotive.config.host.blank? || request.env['locomotive.default_host'].present?

        if request.host != Locomotive.config.host
          options = { host: Locomotive.config.host }
          options[:port] = request.port if request.port != 80

          redirect_to(root_url(**options), allow_other_host: true)
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb
locomotivecms-4.2.0.alpha1 app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb