aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/url.rb
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-03-02 18:57:02 -0800
committerCarl Lerche <carllerche@mac.com>2010-03-03 21:23:34 -0800
commit5e0a05b8cb236d285ebb45de006dd3600c69357d (patch)
tree8fd61eaaa83407c6880bd94c9c3d662cf5c28a84 /actionpack/lib/action_dispatch/http/url.rb
parentbcfb77782b9d7f28f0c19005da909162e5e27690 (diff)
downloadrails-5e0a05b8cb236d285ebb45de006dd3600c69357d.tar.gz
rails-5e0a05b8cb236d285ebb45de006dd3600c69357d.tar.bz2
rails-5e0a05b8cb236d285ebb45de006dd3600c69357d.zip
Tweak the semantic of various URL related methods of ActionDispatch::Request
Diffstat (limited to 'actionpack/lib/action_dispatch/http/url.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/url.rb31
1 files changed, 6 insertions, 25 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb
index 42ad19044d..e67d970a23 100644
--- a/actionpack/lib/action_dispatch/http/url.rb
+++ b/actionpack/lib/action_dispatch/http/url.rb
@@ -85,42 +85,23 @@ module ActionDispatch
subdomains(tld_length).join('.')
end
- # Returns the query string, accounting for server idiosyncrasies.
+ # The query string must always be present
def query_string
- @env['QUERY_STRING'].present? ? @env['QUERY_STRING'] : (@env['REQUEST_URI'].to_s.split('?', 2)[1] || '')
+ @env['QUERY_STRING']
end
# Returns the request URI, accounting for server idiosyncrasies.
# WEBrick includes the full URL. IIS leaves REQUEST_URI blank.
def request_uri
- if uri = @env['REQUEST_URI']
- # Remove domain, which webrick puts into the request_uri.
- (%r{^\w+\://[^/]+(/.*|$)$} =~ uri) ? $1 : uri
- else
- # Construct IIS missing REQUEST_URI from SCRIPT_NAME and PATH_INFO.
- uri = @env['PATH_INFO'].to_s
-
- if script_filename = @env['SCRIPT_NAME'].to_s.match(%r{[^/]+$})
- uri = uri.sub(/#{script_filename}\//, '')
- end
-
- env_qs = @env['QUERY_STRING'].to_s
- uri += "?#{env_qs}" unless env_qs.empty?
-
- if uri.blank?
- @env.delete('REQUEST_URI')
- else
- @env['REQUEST_URI'] = uri
- end
- end
+ uri = "#{@env["SCRIPT_NAME"]}#{@env["PATH_INFO"]}"
+ uri << "?#{@env["QUERY_STRING"]}" if @env["QUERY_STRING"].present?
+ uri
end
# Returns the interpreted \path to requested resource after all the installation
# directory of this application was taken into account.
def path
- path = request_uri.to_s[/\A[^\?]*/]
- path.sub!(/\A#{ActionController::Base.relative_url_root}/, '')
- path
+ @env['PATH_INFO']
end
private