Changeset 3931
- Timestamp:
- 03/18/06 16:45:40 (2 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/request.rb (modified) (1 diff)
- trunk/actionpack/test/controller/request_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r3928 r3931 1 1 *SVN* 2 3 * Add ability for relative_url_root to be specified via an environment variable RAILS_RELATIVE_URL_ROOT. [isaac@reuben.com, Nicholas Seckar] 2 4 3 5 * Fixed link_to "somewhere", :post => true to produce valid XHTML by using the parentnode instead of document.body for the instant form #3007 [Bob Silva] trunk/actionpack/lib/action_controller/request.rb
r3850 r3931 164 164 165 165 # Returns the path minus the web server relative installation directory. 166 # This method returns nil unless the web server is apache. 166 # This can be set with the environment variable RAILS_RELATIVE_URL_ROOT. 167 # It can be automatically extracted for Apache setups. If the server is not 168 # Apache, this method returns an empty string. 167 169 def relative_url_root 168 @@relative_url_root ||= server_software == 'apache' ? @env["SCRIPT_NAME"].to_s.sub(/\/dispatch\.(fcgi|rb|cgi)$/, '') : '' 170 @@relative_url_root ||= case 171 when @env["RAILS_RELATIVE_URL_ROOT"] 172 @env["RAILS_RELATIVE_URL_ROOT"] 173 when server_software == 'apache' 174 @env["SCRIPT_NAME"].to_s.sub(/\/dispatch\.(fcgi|rb|cgi)$/, '') 175 else 176 '' 177 end 169 178 end 170 179 trunk/actionpack/test/controller/request_test.rb
r3467 r3931 106 106 @request.env['SCRIPT_NAME'] = "/collaboration/hieraki" 107 107 assert_equal "/collaboration/hieraki", @request.relative_url_root 108 109 @request.relative_url_root = nil 110 @request.env['SCRIPT_NAME'] = "/hieraki/dispatch.cgi" 111 @request.env['SERVER_SOFTWARE'] = 'lighttpd/1.2.3' 112 @request.env['RAILS_RELATIVE_URL_ROOT'] = "/hieraki" 113 assert_equal "/hieraki", @request.relative_url_root 114 115 # @env overrides path guess 116 @request.relative_url_root = nil 117 @request.env['SCRIPT_NAME'] = "/hieraki/dispatch.cgi" 118 @request.env['SERVER_SOFTWARE'] = 'apache/1.2.3 some random text' 119 @request.env['RAILS_RELATIVE_URL_ROOT'] = "/real_url" 120 assert_equal "/real_url", @request.relative_url_root 108 121 end 109 122