class Rack::SlashMerger

Constants

PATTERN
VERSION

Public Class Methods

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

Public Instance Methods

call(env) click to toggle source
# File lib/rack/slash_merger.rb, line 9
def call(env)
  if env['PATH_INFO'] =~ PATTERN
    new_env = env.merge('PATH_INFO' => env['PATH_INFO'].gsub(PATTERN, '/'))
    [301, {"Location" => Rack::Request.new(new_env).url, "Content-Type" => ""}, []]
  else
    @app.call(env)
  end
end