From c84538ec885cf95aaf3b29523d46883cd349d84d Mon Sep 17 00:00:00 2001 From: Udit Veerwani <25996904+uditdc@users.noreply.github.com> Date: Wed, 25 Oct 2023 22:04:56 +0530 Subject: [PATCH] Encode request body to handle special characters (#112) --- src/commands/function/invoke.ts | 2 +- src/commands/sites/preview.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/function/invoke.ts b/src/commands/function/invoke.ts index 314870a..c74b6a9 100644 --- a/src/commands/function/invoke.ts +++ b/src/commands/function/invoke.ts @@ -124,7 +124,7 @@ export const run = async (options: any) => { envVarsKeys.push('BLS_REQUEST_HEADERS') if (request.body) { - envVars.push(`BLS_REQUEST_BODY="${JSON.stringify(request.body)}"`) + envVars.push(`BLS_REQUEST_BODY="${encodeURIComponent(JSON.stringify(request.body))}"`) envVarsKeys.push('BLS_REQUEST_BODY') } diff --git a/src/commands/sites/preview.ts b/src/commands/sites/preview.ts index 032825d..562ac84 100644 --- a/src/commands/sites/preview.ts +++ b/src/commands/sites/preview.ts @@ -136,7 +136,7 @@ export const run = async (options: any) => { envVarsKeys.push('BLS_REQUEST_HEADERS') if (request.body) { - envVars.push(`BLS_REQUEST_BODY="${JSON.stringify(request.body)}"`) + envVars.push(`BLS_REQUEST_BODY="${encodeURIComponent(JSON.stringify(request.body))}"`) envVarsKeys.push('BLS_REQUEST_BODY') }