Skip to content
Browse files

Merge pull request #10839 from gsamokovarov/clean-normalize_encoded_p…

…aths

Refactor ActionDispatch::Http::Parameters#normalize_encode_params
  • Loading branch information...
2 parents 733115d + 998d03f commit bc8f8026232bdc55ebed24d8326a863036b816fd @rafaelfranca rafaelfranca committed Jun 4, 2013
Showing with 7 additions and 11 deletions.
  1. +7 −11 actionpack/lib/action_dispatch/http/parameters.rb
View
18 actionpack/lib/action_dispatch/http/parameters.rb
@@ -64,17 +64,13 @@ def normalize_encode_params(params)
end
new_hash = {}
- params.each do |k, v|
- new_key = k.is_a?(String) ? k.dup.force_encoding(Encoding::UTF_8).encode! : k
- new_hash[new_key] =
- case v
- when Hash
- normalize_encode_params(v)
- when Array
- v.map! {|el| normalize_encode_params(el) }
- else
- normalize_encode_params(v)
- end
+ params.each do |key, val|
+ new_key = key.is_a?(String) ? key.dup.force_encoding(Encoding::UTF_8).encode! : key
+ new_hash[new_key] = if val.is_a?(Array)
+ val.map! { |el| normalize_encode_params(el) }
+ else
+ normalize_encode_params(val)
+ end
end
new_hash.with_indifferent_access
end

0 comments on commit bc8f802

Please sign in to comment.
Something went wrong with that request. Please try again.