From b27deb7672c53e3ee59f91b7091e83ab28a8318d Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 24 Mar 2024 13:57:49 +0100 Subject: pager: detect JS as text hack so it's possible to view JS code in a buffer even if it's set as e.g. application/javascript in user mime.types --- src/local/pager.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/local/pager.nim b/src/local/pager.nim index b8041236..5bd51fed 100644 --- a/src/local/pager.nim +++ b/src/local/pager.nim @@ -42,6 +42,7 @@ import types/cookie import types/opt import types/url import types/winattrs +import utils/mimeguess import utils/strwidth import utils/twtstr @@ -1603,7 +1604,10 @@ proc connected(pager: Pager; container: Container; response: Response) = container.contentType.get & ";charset=" & $container.charset let mailcapRes = pager.checkMailcap(container, istream, response.outputId, realContentType) - if not mailcapRes.found and not realContentType.startsWithIgnoreCase("text/"): + let shortContentType = container.contentType.get + if not mailcapRes.found and + not shortContentType.startsWithIgnoreCase("text/") and + not shortContentType.isJavaScriptType(): pager.askDownloadPath(container, response) return if mailcapRes.connect: -- cgit 1.4.1-2-gfad0