but non-standard types.
"""
url = os.fspath(url)
- p = urllib.parse.urlparse(url)
- scheme, url = p.scheme, p.path
+ scheme, url = urllib.parse._splittype(url)
if scheme == 'data':
# syntax of data URLs:
# dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
eq(self.db.guess_type('foo.xul', strict=False), ('text/xul', None))
eq(self.db.guess_extension('image/jpg', strict=False), '.jpg')
- def test_url(self):
- result = self.db.guess_type('http://host.html')
- msg = 'URL only has a host name, not a file'
- self.assertSequenceEqual(result, (None, None), msg)
- result = self.db.guess_type('http://example.com/host.html')
- msg = 'Should be text/html'
- self.assertSequenceEqual(result, ('text/html', None), msg)
-
def test_guess_all_types(self):
eq = self.assertEqual
unless = self.assertTrue
["foo", "bar"], "", None),
("ftp://localhost/baz.gif;type=a",
"localhost", ftplib.FTP_PORT, "", "", "A",
- [], "baz.gif", "image/gif"),
+ [], "baz.gif", None), # XXX really this should guess image/gif
]:
req = Request(url)
req.timeout = None
+++ /dev/null
-Update mimetypes.guess_type to allow proper parsing of URLs with only a host name.
-Patch by Dong-hee Na.
--- /dev/null
+Revert GH-15522, which introduces a regression in
+:meth:`mimetypes.guess_type` due to improper handling of filenames as urls.