From caf6ff6a2f7537254b0c88f516e9b0e3347a82b3 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 19 May 2005 18:55:50 +0000 Subject: Cache relative_url_root and optimize path #1232 [skaen] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1325 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/request.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller/request.rb') diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 31d0fb1539..02682b57cf 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -117,7 +117,8 @@ module ActionController # returns the interpreted path to requested resource after # all the installation directory of this application was taken into account def path - path = request_uri ? request_uri.split('?').first : '' + uri = request_uri + path = uri ? uri.split('?').first : '' # cut off the part of the url which leads to the installation directory of this app path[relative_url_root.length..-1] @@ -126,7 +127,7 @@ module ActionController # returns the path minus the web server relative # installation directory def relative_url_root - File.dirname(env["SCRIPT_NAME"].to_s).gsub /(^\.$|^\/$)/, '' + @@relative_url_root ||= File.dirname(env["SCRIPT_NAME"].to_s).gsub /(^\.$|^\/$)/, '' end def port -- cgit v1.2.3