From 197a995bc548e206bb907c40d75f8ed70fa5a923 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Mon, 27 Sep 2010 20:57:26 -0300 Subject: Move uri parser to AS as URI.parser method to reuse it in AP and ARes. --- actionpack/lib/action_controller.rb | 2 +- actionpack/lib/action_controller/caching/actions.rb | 4 +--- actionpack/lib/action_controller/caching/pages.rb | 8 +------- actionpack/lib/action_controller/uri_parser.rb | 9 --------- actionpack/lib/action_dispatch/routing/route_set.rb | 10 ++-------- 5 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 actionpack/lib/action_controller/uri_parser.rb (limited to 'actionpack') diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb index 787439db87..5b81cd39f4 100644 --- a/actionpack/lib/action_controller.rb +++ b/actionpack/lib/action_controller.rb @@ -8,7 +8,6 @@ module ActionController autoload :Caching autoload :Metal autoload :Middleware - autoload :UriParser autoload_under "metal" do autoload :Compatibility @@ -73,4 +72,5 @@ require 'active_support/core_ext/load_error' require 'active_support/core_ext/module/attr_internal' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/name_error' +require 'active_support/core_ext/uri' require 'active_support/inflector' diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index cd352f69fc..d69d96b974 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -141,8 +141,6 @@ module ActionController #:nodoc: end class ActionCachePath - include UriParser - attr_reader :path, :extension # If +infer_extension+ is true, the cache path extension is looked up from the request's @@ -163,7 +161,7 @@ module ActionController #:nodoc: def normalize!(path) path << 'index' if path[-1] == ?/ path << ".#{extension}" if extension and !path.ends_with?(extension) - uri_parser.unescape(path) + URI.parser.unescape(path) end end end diff --git a/actionpack/lib/action_controller/caching/pages.rb b/actionpack/lib/action_controller/caching/pages.rb index f0e00718ac..df4d500069 100644 --- a/actionpack/lib/action_controller/caching/pages.rb +++ b/actionpack/lib/action_controller/caching/pages.rb @@ -57,8 +57,6 @@ module ActionController #:nodoc: end module ClassMethods - include UriParser - # Expires the page that was cached with the +path+ as a key. Example: # expire_page "/lists/show" def expire_page(path) @@ -100,7 +98,7 @@ module ActionController #:nodoc: private def page_cache_file(path) - name = (path.empty? || path == "/") ? "/index" : uri_parser.unescape(path.chomp('/')) + name = (path.empty? || path == "/") ? "/index" : URI.parser.unescape(path.chomp('/')) name << page_cache_extension unless (name.split('/').last || name).include? '.' return name end @@ -112,10 +110,6 @@ module ActionController #:nodoc: def instrument_page_cache(name, path) ActiveSupport::Notifications.instrument("#{name}.action_controller", :path => path){ yield } end - - def uri_parser - @uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI - end end # Expires the page that was cached with the +options+ as a key. Example: diff --git a/actionpack/lib/action_controller/uri_parser.rb b/actionpack/lib/action_controller/uri_parser.rb deleted file mode 100644 index 8e2a3f69eb..0000000000 --- a/actionpack/lib/action_controller/uri_parser.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'uri' - -module ActionController #:nodoc: - module UriParser - def uri_parser - @uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI - end - end -end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 66b487ba6d..66e6ecc74c 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -5,8 +5,6 @@ require 'active_support/core_ext/object/to_query' module ActionDispatch module Routing class RouteSet #:nodoc: - include ActionController::UriParser - PARAMETERS_KEY = 'action_dispatch.request.path_parameters' class Dispatcher #:nodoc: @@ -68,7 +66,7 @@ module ActionDispatch end def split_glob_param!(params) - params[@glob_param] = params[@glob_param].split('/').map { |v| uri_parser.unescape(v) } + params[@glob_param] = params[@glob_param].split('/').map { |v| URI.parser.unescape(v) } end end @@ -546,7 +544,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_parser.unescape(value) + params[key] = URI.parser.unescape(value) end end @@ -563,10 +561,6 @@ 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) -- cgit v1.2.3