forked from LBRYCommunity/lbry-sdk
Merge pull request #1946 from lbryio/file-type-fix
lowercase/stripped comparison for known types
This commit is contained in:
commit
faa1935203
2 changed files with 3 additions and 1 deletions
|
@ -155,6 +155,6 @@ types_map = {
|
||||||
def guess_media_type(path):
|
def guess_media_type(path):
|
||||||
_, ext = os.path.splitext(path)
|
_, ext = os.path.splitext(path)
|
||||||
return types_map.get(
|
return types_map.get(
|
||||||
ext,
|
ext.strip().lower(),
|
||||||
'application/octet-stream' if not (ext and ext[1:].strip()) else f'application/x-ext-{ext[1:].strip().lower()}'
|
'application/octet-stream' if not (ext and ext[1:].strip()) else f'application/x-ext-{ext[1:].strip().lower()}'
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,9 +5,11 @@ from lbrynet.extras.daemon import mime_types
|
||||||
class TestMimeTypes(unittest.TestCase):
|
class TestMimeTypes(unittest.TestCase):
|
||||||
def test_mp4_video(self):
|
def test_mp4_video(self):
|
||||||
self.assertEqual("video/mp4", mime_types.guess_media_type("test.mp4"))
|
self.assertEqual("video/mp4", mime_types.guess_media_type("test.mp4"))
|
||||||
|
self.assertEqual("video/mp4", mime_types.guess_media_type("test.MP4"))
|
||||||
|
|
||||||
def test_x_ext_(self):
|
def test_x_ext_(self):
|
||||||
self.assertEqual("application/x-ext-lbry", mime_types.guess_media_type("test.lbry"))
|
self.assertEqual("application/x-ext-lbry", mime_types.guess_media_type("test.lbry"))
|
||||||
|
self.assertEqual("application/x-ext-lbry", mime_types.guess_media_type("test.LBRY"))
|
||||||
|
|
||||||
def test_octet_stream(self):
|
def test_octet_stream(self):
|
||||||
self.assertEqual("application/octet-stream", mime_types.guess_media_type("test."))
|
self.assertEqual("application/octet-stream", mime_types.guess_media_type("test."))
|
||||||
|
|
Loading…
Reference in a new issue