about summary refs log tree commit diff stats
path: root/src/loader
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-06-21 00:05:25 +0200
committerbptato <nincsnevem662@gmail.com>2024-06-21 00:17:03 +0200
commitb8a21c2407a9898a538852098eca5658de5afd37 (patch)
treee41ad69d5473a4775537ed61707d6d31cce5c104 /src/loader
parent7f66b5ebc88936db974e3320d77c7ec9d4ab85e6 (diff)
downloadchawan-b8a21c2407a9898a538852098eca5658de5afd37.tar.gz
img, term: try to detect unknown images, improve kitty encoder
* preserve alpha in kitty + simplify encoder
* pass unknown image types to stbi (as image/x-unknown) and let it
  detect the type
Diffstat (limited to 'src/loader')
-rw-r--r--src/loader/response.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/loader/response.nim b/src/loader/response.nim
index 2f624a1a..ab74571e 100644
--- a/src/loader/response.nim
+++ b/src/loader/response.nim
@@ -101,13 +101,14 @@ func getCharset*(this: Response; fallback: Charset): Charset =
     return fallback
   return cs
 
-func getContentType*(this: Response): string =
+func getContentType*(this: Response; fallback = "application/octet-stream"):
+    string =
   if "Content-Type" in this.headers.table:
     let header = this.headers.table["Content-Type"][0].toLowerAscii()
     return header.until(';').strip()
   # also use DefaultGuess for container, so that local mime.types cannot
   # override buffer mime.types
-  return DefaultGuess.guessContentType(this.url.pathname)
+  return DefaultGuess.guessContentType(this.url.pathname, fallback)
 
 type TextOpaque = ref object of RootObj
   buf: string