Sha256: 8b6fbbd024e5c677791afea4a8c9a3bba2761ee2cfb5a385ec83b3a555c234ca

Contents?: true

Size: 586 Bytes

Versions: 11

Compression:

Stored size: 586 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'].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

11 entries across 11 versions & 1 rubygems

Version Path
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.5.0.rc0 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.5.0.beta3 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.5.0.beta2 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.5.0.beta1 lib/locomotive/steam/middlewares/path.rb