Created
December 13, 2019 19:09
-
-
Save jasonbot/a42d5e9488dce81400e85a2396db2aca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.parse | |
def order_query_string(url): | |
parsed_url = list(urllib.parse.urlparse(url)) | |
# Put the query string params in determinisitic order. | |
# According to docs.python this is in [3], but docs.python is a liar. | |
parsed_url[4] = urllib.parse.urlencode(sorted(urllib.parse.parse_qsl(parsed_url[4]))) | |
return urllib.parse.urlunparse(parsed_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment