aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-09-22 16:11:15 -0300
committerEmilio Tagua <miloops@gmail.com>2010-09-27 11:19:20 -0300
commit5d773f8dedef85f3ef5d3bdebcedd72716002268 (patch)
tree6051c353ec7258013e864bd56ba443d13b95d178 /actionpack/lib/action_dispatch
parent535371e956b648daff80b1c727b609749ac7137b (diff)
downloadrails-5d773f8dedef85f3ef5d3bdebcedd72716002268.tar.gz
rails-5d773f8dedef85f3ef5d3bdebcedd72716002268.tar.bz2
rails-5d773f8dedef85f3ef5d3bdebcedd72716002268.zip
Remove warning "URI.unescape is obsolete" from actionpack.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb18
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb12
2 files changed, 19 insertions, 11 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index fe85acb94e..8ddf67c0cf 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -395,10 +395,10 @@ module ActionDispatch
# namespace "admin" do
# resources :posts, :comments
# end
- #
+ #
# This will create a number of routes for each of the posts and comments
# controller. For Admin::PostsController, Rails will create:
- #
+ #
# GET /admin/photos
# GET /admin/photos/new
# POST /admin/photos
@@ -406,33 +406,33 @@ module ActionDispatch
# GET /admin/photos/1/edit
# PUT /admin/photos/1
# DELETE /admin/photos/1
- #
+ #
# If you want to route /photos (without the prefix /admin) to
# Admin::PostsController, you could use
- #
+ #
# scope :module => "admin" do
# resources :posts, :comments
# end
#
# or, for a single case
- #
+ #
# resources :posts, :module => "admin"
- #
+ #
# If you want to route /admin/photos to PostsController
# (without the Admin:: module prefix), you could use
- #
+ #
# scope "/admin" do
# resources :posts, :comments
# end
#
# or, for a single case
- #
+ #
# resources :posts, :path => "/admin"
#
# In each of these cases, the named routes remain the same as if you did
# not use scope. In the last case, the following paths map to
# PostsController:
- #
+ #
# GET /admin/photos
# GET /admin/photos/new
# POST /admin/photos
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 1a5f21bd09..b885a573d5 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -66,7 +66,11 @@ module ActionDispatch
end
def split_glob_param!(params)
- params[@glob_param] = params[@glob_param].split('/').map { |v| URI.unescape(v) }
+ params[@glob_param] = params[@glob_param].split('/').map { |v| uri_parser.unescape(v) }
+ end
+
+ def uri_parser
+ @uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
end
@@ -543,7 +547,7 @@ module ActionDispatch
params.each do |key, value|
if value.is_a?(String)
value = value.dup.force_encoding(Encoding::BINARY) if value.encoding_aware?
- params[key] = URI.unescape(value)
+ params[key] = uri_parser.unescape(value)
end
end
@@ -560,6 +564,10 @@ module ActionDispatch
end
private
+ def uri_parser
+ @uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
+ end
+
def handle_positional_args(options)
return unless args = options.delete(:_positional_args)