-
Notifications
You must be signed in to change notification settings - Fork 374
Open
Description
Hi,
I am using boltons to do URL comparisons, being agnostic of the URL representation, and it works great so far except for query parameters.
Typically, with percent encoding, this is working as expected:
>>> a = boltons.urlutils.URL('http://example.com/foo, bar')
>>> b = boltons.urlutils.URL('http://example.com/foo%2C%20bar')
>>> a == b
TrueHowever, when taking query parameters into account, the comparison seems to be ordered (while I would expect the order of query parameters to have no impact). See:
>>> a = boltons.urlutils.URL('http://example.com/foo, bar?foo=bar&bar=foo')
>>> b = boltons.urlutils.URL('http://example.com/foo%2C%20bar?bar=foo&foo=bar')
>>> a == b
FalseI solved the issue with a bit of monkey patching, but is there a reason for having an ordered comparison here?
My solution:
def query_params_dict_eq_monkey_patch(self, other):
"""
>>> a = boltons.urlutils.URL('http://example.com/foo, bar?foo=bar&bar=foo')
>>> b = boltons.urlutils.URL('http://example.com/foo%2C%20bar?bar=foo&foo=bar')
>>> a == b
True
"""
return dict(self) == dict(other)
boltons.urlutils.QueryParamDict.__eq__ = query_params_dict_eq_monkey_patchThanks!
Metadata
Metadata
Assignees
Labels
No labels