◐ Shell
reader mode source ↗
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
27 changes: 27 additions & 0 deletions Lib/test/test_urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,15 @@ def test_splittype(self):
self.assertEqual(splittype('type:'), ('type', ''))
self.assertEqual(splittype('type:opaque:string'), ('type', 'opaque:string'))

def test_splithost(self):
splithost = urllib.parse.splithost
self.assertEqual(splithost('//www.example.org:80/foo/bar/baz.html'),
Expand Down Expand Up @@ -1010,6 +1019,15 @@ def test_splithost(self):
self.assertEqual(splithost("//example.net/file#"),
('example.net', '/file#'))

def test_splituser(self):
splituser = urllib.parse.splituser
self.assertEqual(splituser('User:Pass@www.python.org:080'),
Expand Down Expand Up @@ -1052,6 +1070,15 @@ def test_splitport(self):
self.assertEqual(splitport('[::1]'), ('[::1]', None))
self.assertEqual(splitport(':88'), ('', '88'))

def test_splitnport(self):
splitnport = urllib.parse.splitnport
self.assertEqual(splitnport('parrot:88'), ('parrot', 88))
Expand Down
12 changes: 6 additions & 6 deletions Lib/urllib/parse.py
Original file line number Diff line number Diff line change
@@ -934,9 +934,9 @@ def splittype(url):
"""splittype('type:opaquestring') --> 'type', 'opaquestring'."""
global _typeprog
if _typeprog is None:
_typeprog = re.compile('([^/:]+):(.*)', re.DOTALL)

match = _typeprog.match(url)
if match:
scheme, data = match.groups()
return scheme.lower(), data
Expand All @@ -947,9 +947,9 @@ def splithost(url):
"""splithost('//host[:port]/path') --> 'host[:port]', '/path'."""
global _hostprog
if _hostprog is None:
_hostprog = re.compile('//([^/#?]*)(.*)', re.DOTALL)

match = _hostprog.match(url)
if match:
host_port, path = match.groups()
if path and path[0] != '/':
Expand All @@ -973,9 +973,9 @@ def splitport(host):
"""splitport('host:port') --> 'host', 'port'."""
global _portprog
if _portprog is None:
_portprog = re.compile('(.*):([0-9]*)$', re.DOTALL)

match = _portprog.match(host)
if match:
host, port = match.groups()
if port:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Toggle all file notes Toggle all file annotations