Skip to content

Commit 3fe8a1a

Browse files
committed
Merge branch 'normalize-urls-correctly' of https://github.com/joestump/python-oauth2
2 parents 91273d9 + 6f06c89 commit 3fe8a1a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

oauth10a/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def url(self, value):
383383

384384
# Normalized URL excludes params, query, and fragment.
385385
self.normalized_url = urlunsplit(
386-
(scheme, netloc, path, None, None)
386+
(scheme.lower(), netloc.lower(), path, None, None)
387387
)
388388
else:
389389
self.normalized_url = None

tests/test_oauth.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,14 @@ def test_url(self):
386386
self.assertEqual(req.normalized_url, exp2)
387387
self.assertEqual(req.url, url2)
388388

389+
def test_url_lowercases_scheme_and_authority(self):
390+
"""Lowercase scheme and authority in URL normalization."""
391+
# http://oauth.net/core/1.0a/#rfc.section.9.1.2
392+
# https://github.com/joestump/python-oauth2/issues/29
393+
url = 'HTTP://Example.com/resource'
394+
req = oauth.Request("GET", url)
395+
self.assertEquals(req.normalized_url, "http://example.com/resource")
396+
389397
def test_bad_url(self):
390398
request = oauth.Request()
391399
try:

0 commit comments

Comments
 (0)