diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2011-12-20 20:17:17 +0100 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2012-01-10 04:39:43 +0100 |
commit | 63305daeba3d85442b3a84d4df0c83f59250c7cb (patch) | |
tree | 53127670f46fb10da6a9bc46cbbca1318582cf18 /railties/lib | |
parent | a579d4bb5f1ec1166762f9365c5e3bb2c49225dd (diff) | |
download | rails-63305daeba3d85442b3a84d4df0c83f59250c7cb.tar.gz rails-63305daeba3d85442b3a84d4df0c83f59250c7cb.tar.bz2 rails-63305daeba3d85442b3a84d4df0c83f59250c7cb.zip |
Add ORIGINAL_FULLPATH to env
This behaves similarly to REQUEST_URI, but
we need to implement it on our own because
REQUEST_URI is not reliable.
Note that since PATH_INFO does not contain
information about trailing question mark,
this is not 100% accurate, for example
`/foo?` will result in `/foo` in ORIGINAL_FULLPATH
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index b20634c5a9..19e8426e60 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -215,6 +215,11 @@ module Rails config.helpers_paths end + def call(env) + env["ORIGINAL_FULLPATH"] = build_original_fullpath(env) + super(env) + end + protected alias :build_middleware_stack :app @@ -291,5 +296,17 @@ module Rails require "rails/console/app" require "rails/console/helpers" end + + def build_original_fullpath(env) + path_info = env["PATH_INFO"] + query_string = env["QUERY_STRING"] + script_name = env["SCRIPT_NAME"] + + if query_string.present? + "#{script_name}#{path_info}?#{query_string}" + else + "#{script_name}#{path_info}" + end + end end end |