Added support for more json type headers
This commit is contained in:
2
index.js
2
index.js
@@ -349,7 +349,7 @@ class Router {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
const headers = Object.assign({ 'Content-Type': 'application/json' }, response.headers)
|
const headers = Object.assign({ 'Content-Type': 'application/json' }, response.headers)
|
||||||
if (headers['Content-Type'] === 'application/json' && typeof response.body === 'object')
|
if (headers['Content-Type'].includes('json') && typeof response.body === 'object')
|
||||||
response.body = JSON.stringify(response.body)
|
response.body = JSON.stringify(response.body)
|
||||||
return new Response(response.body, {
|
return new Response(response.body, {
|
||||||
status: response.status || (response.body ? 200 : 500),
|
status: response.status || (response.body ? 200 : 500),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tsndr/cloudflare-worker-router",
|
"name": "@tsndr/cloudflare-worker-router",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {},
|
"scripts": {},
|
||||||
|
|||||||
Reference in New Issue
Block a user