@tinyhttp/send
Advanced tools
Comparing version 1.2.6 to 1.3.0
@@ -53,16 +53,17 @@ import { format, parse } from 'es-content-type'; | ||
let bodyToSend = body; | ||
// in case of object - turn it to json | ||
if (typeof body === 'object' && body !== null) { | ||
if (Buffer.isBuffer(body)) { | ||
bodyToSend = body; | ||
} | ||
else if (typeof body === 'object' && body !== null) { | ||
// in case of object - turn it to json | ||
bodyToSend = JSON.stringify(body, null, 2); | ||
} | ||
else { | ||
if (typeof body === 'string') { | ||
// reflect this in content-type | ||
const type = res.getHeader('Content-Type'); | ||
if (type && typeof type === 'string') { | ||
res.setHeader('Content-Type', setCharset(type, 'utf-8')); | ||
} | ||
else | ||
res.setHeader('Content-Type', setCharset('text/html', 'utf-8')); | ||
else if (typeof body === 'string') { | ||
// reflect this in content-type | ||
const type = res.getHeader('Content-Type'); | ||
if (type && typeof type === 'string') { | ||
res.setHeader('Content-Type', setCharset(type, 'utf-8')); | ||
} | ||
else | ||
res.setHeader('Content-Type', setCharset('text/html', 'utf-8')); | ||
} | ||
@@ -95,2 +96,3 @@ // Set encoding | ||
res.setHeader('content-type', 'application/octet-stream'); | ||
res.end(bodyToSend); | ||
} | ||
@@ -97,0 +99,0 @@ else |
{ | ||
"name": "@tinyhttp/send", | ||
"version": "1.2.6", | ||
"version": "1.3.0", | ||
"type": "module", | ||
@@ -39,3 +39,3 @@ "description": "json, send, sendFile, status and sendStatus methods for tinyhttp", | ||
"dependencies": { | ||
"@tinyhttp/etag": "1.2.2", | ||
"@tinyhttp/etag": "1.3.0", | ||
"es-content-type": "^0.0.10", | ||
@@ -42,0 +42,0 @@ "es-mime-types": "^0.0.16" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22187
477
+ Added@tinyhttp/etag@1.3.0(transitive)
- Removed@tinyhttp/etag@1.2.2(transitive)
Updated@tinyhttp/etag@1.3.0