Skip to content

Commit

Permalink
v3.2.12 - fix content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-lemon committed Jan 14, 2025
1 parent b715b2e commit 95aad9a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ See [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md)

| Version | Description
|-- |--
| 3.2.12 | improve `buildResponse()` to determin content-type of html.
| 3.2.11 | updated `elastic6-service` to support `SearchProxy`.
| 3.2.10 | updated `elastic6-service` to fix `400 ILLEGAL ARGUMENT` (script parsing).
| 3.2.9 | improve `elastic6-service` w/ latest open-search.
| 3.2.8 | updated `ttypescript^1.5.15`, and optimized.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lemon-core",
"version": "3.2.11",
"version": "3.2.12",
"description": "Lemon Serverless Micro-Service Platform",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion src/cores/lambda/lambda-web-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ type ProxyChain = ProxyParams | ProxyResponser;
*/
export const buildResponse = (statusCode: number, body: any, contentType?: string, origin?: string): ProxyResult => {
const isBase64Encoded = contentType && !contentType.startsWith('text/') ? true : false;
const _isHtml = (body: string) =>
body.startsWith('<!DOCTYPE html>') || (body.startsWith('<') && body.endsWith('>'));
contentType =
contentType ||
(typeof body === 'string'
? body.startsWith('<') && body.endsWith('>')
? _isHtml(body)
? 'text/html; charset=utf-8'
: 'text/plain; charset=utf-8'
: 'application/json; charset=utf-8');
Expand Down

0 comments on commit 95aad9a

Please sign in to comment.