From 27b25bc05f9ef66eff8cf727b2fffecc2fb42313 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Sun, 19 Apr 2026 10:28:52 +0200 Subject: [PATCH] fix: Override server JS MIME type if `text/plain` On systems such as Windows, JavaScript files can be incorrectly assigned the "text/plain" MIME type in Python's mimetypes module. This overrides this behavior when it occurs. --- pelican/server.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pelican/server.py b/pelican/server.py index c4607e21..92b6ad76 100644 --- a/pelican/server.py +++ b/pelican/server.py @@ -120,6 +120,11 @@ class ComplexHTTPRequestHandler(server.SimpleHTTPRequestHandler): if mimetype == "application/octet-stream" and magic_from_file: mimetype = magic_from_file(path, mime=True) + # On some systems, JavaScript files are incorrectly assigned the "text/plain" + # MIME type in Python's mimetypes module. Override this behavior when it occurs. + if posixpath.splitext(path)[1] == ".js" and mimetype == "text/plain": + mimetype = "text/javascript" + return mimetype def log_message(self, msg_format, *args):