class Rack::Slashless
Public Class Methods
new(app)
click to toggle source
# File lib/rack_slashless.rb, line 4 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack_slashless.rb, line 8 def call(env) request = Rack::Request.new(env) if request.get? && request.path_info.match(/.+\/$/) destination = request.url.gsub(/\/(\?.*)?$/,'\1') [301, {'Location' => destination, 'Content-Type' => 'text/html'}, ["Redirecting to #{destination}"]] else @app.call(env) end end