Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

URI comparison fails if their query values are of different order #74

Closed
mislav opened this Issue Feb 18, 2011 · 2 comments

Comments

Projects
None yet
2 participants

mislav commented Feb 18, 2011

Webmock uses Addressable::URI and its === method for matching URIs. This has one flaw, which is that matching fails if two urls are identical sans the fact that their query values are in different order:

u1 = Addressable::URI.parse '/path?foo=bar&baz=kuuq'
u2 = Addressable::URI.parse '/path?baz=kuuq&foo=bar'
u1 === u2  #=> false

This means that if you've stubbed an http response using u1, an HTTP request to a path in form of u2 is not going to match this and is going to fail.

I've submitted this as bug 28 in Addressable but it's not going to get fixed.

I've monkeypatched Addressable for myself but I don't think this is a way to go. I think Webmock should have its own method for URI comparison: it can use Addressable::URI#=== to compare everything up to query string, but then it should compare query strings itself by ignoring query value order.

Collaborator

jcf commented May 28, 2011

This issue has been fixed by sorting query values in WebMock::Util::URI.

@jcf jcf closed this May 28, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment