Sha256: a988adaac051c07cae28cab4ede517080e4935a6689a830314e9839c5e69aa8a

Contents?: true

Size: 753 Bytes

Versions: 21

Compression:

Stored size: 753 Bytes

Contents

module Locomotive::Steam
  module Middlewares

    # If an old URL has been found among the site url_redirections hash,
    # perform a 310 redirection to the new URL.
    # It is highly useful when the site existed before but was ran by another system.
    #
    # See the specs (spec/unit/middlewares/url_redirection_spec.rb) for more details.
    #
    class UrlRedirection < ThreadSafe

      include Helpers

      def _call
        if url = redirect_url
          redirect_to url
        end
      end

      protected

      def redirect_url
        return false if site.url_redirections.nil? || site.url_redirections.size == 0

        site.url_redirections.to_h[request.env['locomotive.path'] || request.fullpath]
      end

    end
  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
locomotivecms_steam-1.1.2 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.2.1 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.2.0 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.2.0.rc3 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.2.0.rc2 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.2.0.rc1 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.2.0.beta1 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.1.1 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.1.0 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.1.0.rc3 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.1.0.rc2 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.1.0.rc1 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.0.1 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.0.0 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.0.0.rc10 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.0.0.rc9 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.0.0.rc8 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.0.0.rc6 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.0.0.rc4 lib/locomotive/steam/middlewares/url_redirection.rb
locomotivecms_steam-1.0.0.rc3 lib/locomotive/steam/middlewares/url_redirection.rb