Permalink
Browse files

Fix request's path_info when a rack app mounted at '/'.

Fixes issue #15511.
  • Loading branch information...
1 parent b0f07ab commit 4a9d4c85c3ad188d188104a7154d916aab079146 @larrylv larrylv committed Jun 12, 2014
View
@@ -1,3 +1,9 @@
+* Fix env['PATH_INFO'] missing leading slash when a rack app mounted at '/'.
+
+ Fixes #15511.
+
+ *Larry Lv*
+
* ActionController::Parameters#require now accepts `false` values.
Fixes #15685.
@@ -35,6 +35,7 @@ def serve(req)
unless route.path.anchored
req.script_name = (script_name.to_s + match.to_s).chomp('/')
req.path_info = match.post_match
+ req.path_info = "/" + req.path_info unless req.path_info.start_with? "/"
end
req.path_parameters = set_params.merge parameters
@@ -31,6 +31,8 @@ def self.call(env)
resources :users do
mount FakeEngine, :at => "/fakeengine", :as => :fake_mounted_at_resource
end
+
+ mount SprocketsApp, :at => "/", :via => :get
end
def app
@@ -44,6 +46,11 @@ def test_app_name_is_properly_generated_when_engine_is_mounted_in_resources
"A named route should be defined with a parent's prefix"
end
+ def test_mounting_at_root_path
+ get "/omg"
+ assert_equal " -- /omg", response.body
+ end
+
def test_mounting_sets_script_name
get "/sprockets/omg"
assert_equal "/sprockets -- /omg", response.body

1 comment on commit 4a9d4c8

I think this patch is not sufficient, because the wrong stripped path_info is passed, when cascading in router.rb:77. Either apply the same patch there or patch path_info before assigning it to env['PATH_INFO']

Please sign in to comment.