From 3b329ec8f771596cd35a0af560881ae549085901 Mon Sep 17 00:00:00 2001 From: Udit Date: Wed, 20 Sep 2023 20:52:06 +0530 Subject: [PATCH] Encode request body to handle special characters --- 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 b390154..3ed8ce1 100644 --- a/src/commands/function/invoke.ts +++ b/src/commands/function/invoke.ts @@ -123,7 +123,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 e07d8d5..1c78d77 100644 --- a/src/commands/sites/preview.ts +++ b/src/commands/sites/preview.ts @@ -135,7 +135,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') }