Sha256: 3acdd0c69bb9f7fc1cdca0846564a6a1b9227981052b2393f7f8e901ca777ca9

Contents?: true

Size: 469 Bytes

Versions: 4

Compression:

Stored size: 469 Bytes

Contents

module Locomotive
  module Middlewares
    class SeoTrailingSlash < Base

      def initialize(app, opts = {})
        @app = app
      end

      def call(env)
        request = Rack::Request.new(env)

        path = request.path

        if !is_backoffice?(request) && path.size > 1 && path.ends_with?('/')
          url = modify_url(request, request.path.chop)
          redirect_to(url)
        else
          @app.call(env)
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locomotive_cms-2.5.7 lib/locomotive/middlewares/seo_trailing_slash.rb
locomotive_cms-2.5.6 lib/locomotive/middlewares/seo_trailing_slash.rb
locomotive_cms-2.5.6.rc2 lib/locomotive/middlewares/seo_trailing_slash.rb
locomotive_cms-2.5.6.rc1 lib/locomotive/middlewares/seo_trailing_slash.rb