mirror of
https://github.com/getpelican/pelican.git
synced 2026-05-31 02:16:56 +02:00
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.
This commit is contained in:
parent
e4c0bf626f
commit
27b25bc05f
1 changed files with 5 additions and 0 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue