aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller')
-rwxr-xr-xactionpack/lib/action_controller/request.rb15
-rw-r--r--actionpack/lib/action_controller/url_rewriter.rb7
2 files changed, 17 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb
index 429b3b9017..6e73a69ed7 100755
--- a/actionpack/lib/action_controller/request.rb
+++ b/actionpack/lib/action_controller/request.rb
@@ -84,9 +84,20 @@ module ActionController
def ssl?
protocol == 'https://'
end
-
+
+ # returns the interpreted path to requested resource after
+ # all the installation directory of this application was taken into account
def path
- request_uri ? request_uri.split('?').first : ''
+ path = request_uri ? request_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]
+ end
+
+ # returns the path minus the web server relative
+ # installation directory
+ def relative_url_root
+ File.dirname(env["SCRIPT_NAME"].to_s).gsub /(^\.$|^\/$)/, ''
end
def port
diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb
index bbfa6009a4..3e6ccf7a06 100644
--- a/actionpack/lib/action_controller/url_rewriter.rb
+++ b/actionpack/lib/action_controller/url_rewriter.rb
@@ -2,13 +2,13 @@ module ActionController
# Rewrites URLs for Base.redirect_to and Base.url_for in the controller.
class UrlRewriter #:nodoc:
- RESERVED_OPTIONS = [:anchor, :params, :only_path, :host, :protocol]
+ RESERVED_OPTIONS = [:anchor, :params, :only_path, :host, :protocol, :application_prefix]
def initialize(request, parameters)
@request, @parameters = request, parameters
@rewritten_path = @request.path ? @request.path.dup : ""
end
- def rewrite(options = {})
+ def rewrite(options = {})
rewrite_url(rewrite_path(options), options)
end
@@ -20,11 +20,12 @@ module ActionController
private
def rewrite_url(path, options)
+
rewritten_url = ""
rewritten_url << (options[:protocol] || @request.protocol) unless options[:only_path]
rewritten_url << (options[:host] || @request.host_with_port) unless options[:only_path]
- rewritten_url << options[:application_prefix] if options[:application_prefix]
+ rewritten_url << (options[:application_prefix] || @request.relative_url_root)
rewritten_url << path
rewritten_url << "##{options[:anchor]}" if options[:anchor]