Skip to content

Fix Rack::AcceptFormat can't handler url which end with slash, and that will raise 406 #40

Merged
merged 1 commit into from Dec 10, 2012
View
2 lib/rack/contrib/accept_format.rb
@@ -37,7 +37,7 @@ def call(env)
if ::File.extname(req.path_info).empty?
accept = env['HTTP_ACCEPT'].to_s.scan(/[^;,\s]*\/[^;,\s]*/)[0].to_s
extension = Rack::Mime::MIME_TYPES.invert[accept] || @ext
- req.path_info = req.path_info+"#{extension}"
+ req.path_info = req.path_info.chomp('/') << "#{extension}"
end
@app.call(env)
Something went wrong with that request. Please try again.