class RackPathInfoFix

Rack PathInfo Fix

This class is a Rack Middleware that fixes up PATH_INFO to be correct for Rack based apps.

Public Class Methods

new(app) click to toggle source
# File lib/rack_pathinfo_fix.rb, line 6
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack_pathinfo_fix.rb, line 10
def call(env)
  pi = env['PATH_INFO']
  sn = env['SCRIPT_NAME']

  if pi != sn
    env['PATH_INFO'] = File.join(sn, pi)
  end

  @app.call env
end