Skip to content

Commit

Permalink
Merge pull request #7 from mdamien/order-get-params
Browse files Browse the repository at this point in the history
Order GET parameters alphabetically
  • Loading branch information
niksite authored Oct 28, 2017
2 parents d027911 + 2713b4f commit 3ee4057
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tests/test_url_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
(False, "http://127.0.0.1:80/"),
(True, "http://www.w3.org/2000/01/rdf-schema#"),
(False, "http://example.com:081/"),
(True, "http://example.com/?a&b"),
(False, "http://example.com/?b&a"),
]


Expand Down
4 changes: 2 additions & 2 deletions url_normalize/url_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def url_normalize(url, charset='utf-8'):

# note care must be taken to only encode & and = characters as values
query = "&".join(
["=".join(
sorted(["=".join(
[quote(_clean(t), "~:/?#[]@!$'()*+,;=")
for t in q.split("=", 1)]) for q in query.split("&")])
for t in q.split("=", 1)]) for q in query.split("&")]))

# Prevent dot-segments appearing in non-relative URI paths.
if scheme in ["", "http", "https", "ftp", "file"]:
Expand Down

0 comments on commit 3ee4057

Please sign in to comment.