Sha256: e90e518790275a845a7a234f0a61d399e034bcfa0c74e4363463c6c5e5739184

Contents?: true

Size: 585 Bytes

Versions: 7

Compression:

Stored size: 585 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 < Struct.new(:app)

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

      protected

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

        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

7 entries across 7 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.pre.beta.3 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.0.0.pre.beta.2 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.0.0.pre.beta.1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.0.0.pre.alpha.3 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.0.0.pre.alpha.2 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.0.0.pre.alpha.1 lib/locomotive/steam/middlewares/path.rb
locomotivecms_steam-1.0.0.pre.alpha lib/locomotive/steam/middlewares/path.rb