From 977f09c47061ce0c922314cc2c8953045ca45ff2 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 5 Nov 2021 00:29:25 +0100 Subject: [PATCH] .txt.gz is not actually .txt --- copyparty/util.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/copyparty/util.py b/copyparty/util.py index 19d96bf6..6683aac8 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -1280,7 +1280,14 @@ def guess_mime(url, fallback="application/octet-stream"): except: return fallback - ret = MIMES.get(ext) or mimetypes.guess_type(url)[0] or fallback + ret = MIMES.get(ext) + + if not ret: + x = mimetypes.guess_type(url) + ret = "application/{}".format(x[1]) if x[1] else x[0] + + if not ret: + ret = fallback if ";" not in ret: if ret.startswith("text/") or ret.endswith("/javascript"):