Ticket #883: route_paths_as_arrays.patch
| File route_paths_as_arrays.patch, 2.8 kB (added by Ulysses, 4 years ago) |
|---|
-
actionpack/lib/action_controller/routing.rb
old new 47 47 48 48 used_names = @requirements.inject({}) {|hash, (k, v)| hash[k] = true; hash} # Mark requirements as used so they don't get put in the query params 49 49 components = @items.collect do |item| 50 50 51 if item.kind_of? Symbol 51 52 collection = false 52 53 … … 69 70 else 70 71 value = Routing.extract_parameter_value(value).gsub(/%2F/, "/") 71 72 end 73 value 72 74 else 73 75 Routing.extract_parameter_value(value) 74 76 end … … 117 119 options[:controller] = controller_class.controller_path 118 120 return nil, requirements_for(:controller) unless passes_requirements?(:controller, options[:controller]) 119 121 elsif /^\*/ =~ item.to_s 120 value = components.empty? @defaults[item].clone : components.clone122 value = components.empty? ? @defaults[item].clone : components.clone 121 123 value.collect! {|c| CGI.unescape c} 122 124 components = [] 123 def value.to_s() self.join('/') 125 def value.to_s() self.join('/') end 124 126 options[item.to_s.sub(/^\*/,"").intern] = value 125 127 elsif item.kind_of? Symbol 126 128 value = components.shift || @defaults[item] -
actionpack/test/controller/routing_tests.rb
old new 329 329 def test_path_collection 330 330 route '*path_info', :controller => 'content', :action => 'fish' 331 331 verify_recognize'path/with/slashes', 332 :controller => 'content', :action => 'fish', :path_info => 'path/with/slashes'332 :controller => 'content', :action => 'fish', :path_info => %w(path with slashes) 333 333 verify_generate('path/with/slashes', {}, 334 {:controller => 'content', :action => 'fish', :path_info => 'path/with/slashes'},334 {:controller => 'content', :action => 'fish', :path_info => 'path/with/slashes'}, 335 335 {}) 336 336 end 337 def test_path_collection_with_array 338 route '*path_info', :controller => 'content', :action => 'fish' 339 verify_recognize'path/with/slashes', 340 :controller => 'content', :action => 'fish', :path_info => %w(path with slashes) 341 verify_generate('path/with/slashes', {}, 342 {:controller => 'content', :action => 'fish', :path_info => %w(path with slashes)}, 343 {}) 344 end 345 346 337 347 338 348 def test_special_characters 339 349 route ':id', :controller => 'content', :action => 'fish'