diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2013-06-21 08:51:28 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2013-06-21 08:56:19 +0200 |
commit | 50311f1391ddd8e0349d74eb57f04b7e0045a27d (patch) | |
tree | ac64667f829e7790f3d7c1d65fe81b8b981f64a3 /actionpack/lib | |
parent | 5ac22989d3f18bd3bf1011ca5ffd0a045e394d2c (diff) | |
download | rails-50311f1391ddd8e0349d74eb57f04b7e0045a27d.tar.gz rails-50311f1391ddd8e0349d74eb57f04b7e0045a27d.tar.bz2 rails-50311f1391ddd8e0349d74eb57f04b7e0045a27d.zip |
Don't remove trailing slash from PATH_INFO for mounted apps
Previously when app was mounted as following:
class Foo
def call(env)
[200, {}, [env['PATH_INFO']]]
end
end
RackMountRailsBug::Application.routes.draw do
mount RackTest.new => "/foo"
end
trailing slash was removed from PATH_INFO. For example requesting
GET /foo/bar/
on routes defined above would result in a response containing "/foo/bar"
instead of "/foo/bar/".
This commit fixes the issue.
(closes #3215)
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/router.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/journey/router.rb b/actionpack/lib/action_dispatch/journey/router.rb index 419e665d12..da32f1bfe7 100644 --- a/actionpack/lib/action_dispatch/journey/router.rb +++ b/actionpack/lib/action_dispatch/journey/router.rb @@ -54,7 +54,7 @@ module ActionDispatch end def call(env) - env['PATH_INFO'] = Utils.normalize_path(env['PATH_INFO']) + env['PATH_INFO'] = normalize_path(env['PATH_INFO']) find_routes(env).each do |match, parameters, route| script_name, path_info, set_params = env.values_at('SCRIPT_NAME', @@ -103,6 +103,12 @@ module ActionDispatch private + def normalize_path(path) + path = "/#{path}" + path.squeeze!('/') + path + end + def partitioned_routes routes.partitioned_routes end |