diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index a6e7ee8..94b54e2 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -795,7 +795,13 @@ class UrlParseTestCase(unittest.TestCase): self.assertRaises(TypeError, urllib.parse.quote, b'foo', encoding='utf-8') self.assertRaises(TypeError, urllib.parse.quote, b'foo', errors='strict') - + def test_websocket_draft17(self): + self.assertEqual(urllib.parse.urlparse("ws://example.com/stuff"), + ('ws', 'example.com', '/stuff', '', '', '')) + self.assertEqual(urllib.parse.urlparse("wss://example.com/stuff?a=b"), + ('wss', 'example.com', '/stuff', '', 'a=b', '')) + self.assertEqual(urllib.parse.urlparse("ws://example.com/stuff#ff"), + ('ws', 'example.com', '/stuff#ff', '', '', '')) def test_main(): support.run_unittest(UrlParseTestCase) diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index 01067ae..3727165 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -39,18 +39,18 @@ __all__ = ["urlparse", "urlunparse", "urljoin", "urldefrag", uses_relative = ['ftp', 'http', 'gopher', 'nntp', 'imap', 'wais', 'file', 'https', 'shttp', 'mms', 'prospero', 'rtsp', 'rtspu', '', 'sftp', - 'svn', 'svn+ssh'] + 'svn', 'svn+ssh', 'ws', 'wss'] uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet', 'imap', 'wais', 'file', 'mms', 'https', 'shttp', 'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '', - 'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh'] + 'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh', 'ws', 'wss'] non_hierarchical = ['gopher', 'hdl', 'mailto', 'news', 'telnet', 'wais', 'imap', 'snews', 'sip', 'sips'] uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap', 'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips', - 'mms', '', 'sftp'] + 'mms', '', 'sftp', 'ws', 'wss'] uses_query = ['http', 'wais', 'imap', 'https', 'shttp', 'mms', - 'gopher', 'rtsp', 'rtspu', 'sip', 'sips', ''] + 'gopher', 'rtsp', 'rtspu', 'sip', 'sips', '', 'ws', 'wss'] uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news', 'nntp', 'wais', 'https', 'shttp', 'snews', 'file', 'prospero', '']