Skip to content

Unordered query params and URL.__eq__ #664

Answered by asvetlov
bsolomon1124 asked this question in Q&A
Discussion options

You must be logged in to vote

The strict comparison rule is: URLs are equal if their string representations are equal.
The relaxed rule applies string representation equality to normalized URL (the normalization procedure is not strictly specified by RCF but still we can have an informal consensus here).
Query params reordering is unlikely a subject for URL normalization in any sense. Moreover, it can change the server behavior easily. That's why YARL processes such URLs as different objects.

If in your particular case the query parameters order doesn't matter, you can use a hand-written url_cmp(url1, url2) function that does what do you want, the sorting url.query by keys including.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bsolomon1124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants