You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been thinking about introducing a sorted_query field, but I'm pretty sure that using this behavior by default in the === method would be a mistake.
If implemented, it would use the OAuth normalization algorithm.
You didn't say why you think this would be a mistake.
I wouldn't close this so soon. This bit me in Webmock; it's a library where you stub a HTTP response by defining a URL and then, when that URL is requested, it returns a fake response. It compares URLs with the === operator, but was failing in some tests because of inconsistent query values ordering. Inconsistent ordering originated from the fact that hashes in 1.8 are unordered, and query values were populated from params in a hash.
If I had to get around this issue without patching Addressable, I would have to either ensure that query values are of consistent ordering when I build URIs (this would require a rewrite of a lot of my code; for instance I couldn't use URI#query_values=() anymore) or I would have to patch Webmock to do a custom URL comparison. The latter 'solution' kinda defeats the purpose of using Addressable in the first place.
Two query strings can only be compared as strings if they are normalized and sorted.
The comparison here should result in true because query values order shouldn't matter.
Here's my monkeypatch: https://gist.github.com/832913
It's crude. I'd like some thoughts on this. I know that some server applications accept arrays in queries, eg.:
In this case, ordering is important. Maybe I should change my patch to just sort across keys and not across "key=value" pairs.
The text was updated successfully, but these errors were encountered: