Permalink
Browse files

Only flatten uri query params to one level

Only tests that the error is not raised, doesn't check actual behaviour
not sure how to test that, as normalized uri is very different to
original.
  • Loading branch information...
1 parent 0c0274d commit 7a5039375ce4376fe7dd52ed73b11d032f26baaf @tooky tooky committed May 25, 2010
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/webmock/util/uri.rb
View
@@ -16,7 +16,7 @@ def self.normalize_uri(uri)
return uri if uri.is_a?(Regexp)
uri = 'http://' + uri unless uri.match('^https?://') if uri.is_a?(String)
normalized_uri = Addressable::URI.heuristic_parse(uri)
- normalized_uri.query_values = Hash[*normalized_uri.query_values.sort.flatten] if normalized_uri.query_values
+ normalized_uri.query_values = sort_query_values(normalized_uri.query_values) if normalized_uri.query_values
normalized_uri = normalized_uri.normalize #normalize! is slower
normalized_uri.port = normalized_uri.inferred_port unless normalized_uri.port
normalized_uri
@@ -57,6 +57,10 @@ def self.encode_unsafe_chars_in_userinfo(userinfo)
private
+ def self.sort_query_values(query_values)
+ Hash[*query_values.sort.inject([]) { |values, pair| values + pair}]
+ end
+
def self.uris_with_inferred_port_and_without(uris)
uris.map { |uri| [ uri, uri.gsub(%r{(:80)|(:443)}, "").freeze ] }.flatten
end

0 comments on commit 7a50393

Please sign in to comment.