Skip to content

Commit

Permalink
Bug fixed: sorting query parameters from URI objects at register uri …
Browse files Browse the repository at this point in the history
…time.
  • Loading branch information
anselmoalves committed Apr 28, 2009
1 parent f62cf41 commit 95428dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/fake_web/registry.rb
Expand Up @@ -58,8 +58,10 @@ def response_for(method, uri, &block)
def normalize_uri(uri)
normalized_uri =
case uri
when URI then uri
else
when URI then
uri.query = sort_query_params(uri.query)
uri
else
uri = 'http://' + uri unless uri.match('^https?://')
parsed_uri = URI.parse(uri)
parsed_uri.query = sort_query_params(parsed_uri.query)
Expand Down
5 changes: 5 additions & 0 deletions test/test_query_string.rb
Expand Up @@ -16,6 +16,11 @@ def test_register_uri_with_query_params_and_check_in_different_order
assert FakeWeb.registered_uri?('http://example.com/?b=1&a=1')
end

def test_register_uri_with_query_params_unsorted_from_uri_object
FakeWeb.register_uri(URI.join('http://example.com/?b=1&a=1'), :string => 'foo')
assert FakeWeb.registered_uri?('http://example.com/?b=1&a=1')
end

def test_registered_uri_gets_recognized_with_empty_query_params
FakeWeb.register_uri('http://example.com/', :string => 'foo')
assert FakeWeb.registered_uri?('http://example.com/?')
Expand Down

0 comments on commit 95428dd

Please sign in to comment.