Sha256: 6be4aa13d77830cc306201b352344ddce6ce3742e594ad29b62b11db0fb8ef36

Contents?: true

Size: 609 Bytes

Versions: 30

Compression:

Stored size: 609 Bytes

Contents

module Locomotive::Steam
  module Middlewares

    # Sanitize the path from the previous middleware in order
    # to make it work for the renderer.
    #
    class Path

      attr_accessor_initialize :app

      def call(env)
        set_path!(env)
        app.call(env)
      end

      protected

      def set_path!(env)
        path = (env['steam.path'] || request.path_info).dup

        path.gsub!(/\.[a-zA-Z][a-zA-Z0-9]{2,}$/, '')
        path.gsub!(/^\//, '')
        path.gsub!(/^[A-Z]:\//, '')

        path = 'index' if path.blank?

        env['steam.path'] = path
      end

    end

  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
locomotivecms_steam-1.4.1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.4.0 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.4.0.rc2 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.4.0.rc1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.4.0.pre.rc.1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.3.0 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.3.0.rc2 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.1.2 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.2.1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.3.0.rc1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.2.0 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.2.0.rc3 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.2.0.rc2 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.2.0.rc1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.2.0.beta1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.1.1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.1.0 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.1.0.rc3 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.1.0.rc2 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.1.0.rc1 lib/locomotive/steam/middlewares/path.rb