Sha256: b8c6952640f0cc41289326d277c5c6d5844010e12a83089c4c05348f1f291715

Contents?: true

Size: 595 Bytes

Versions: 22

Compression:

Stored size: 595 Bytes

Contents

module Locomotive::Wagon
  class Server

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

      def call(env)
        self.set_accessors(env)

        self.set_path!(env)

        app.call(env)
      end

      protected

      def set_path!(env)
        path = env['PATH_INFO'].clone

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

        path = 'index' if path.blank?

        env['wagon.path'] = path
      end

    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
locomotivecms_wagon-1.5.8 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.5.7 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.5.6 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.5.5 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.5.4 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.5.3 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.5.2 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.5.1 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.5.0 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.5.0.rc1 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.4.0 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.3.3 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.3.2 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.3.1 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.3.0 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.2.2 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.2.1 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.2.0 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.1.0 lib/locomotive/wagon/server/path.rb
locomotivecms_wagon-1.0.2 lib/locomotive/wagon/server/path.rb