From 26da3e18a9de04e6563cdb10ea767dc4c6aebb4f Mon Sep 17 00:00:00 2001 From: Muhammed Ajmal M <55492635+ajmalmohad@users.noreply.github.com> Date: Mon, 4 Dec 2023 00:49:45 +0530 Subject: [PATCH] fix(common): prevented truncating parameters (#3502) --- .../hoppscotch-common/src/helpers/new-codegen/har.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/hoppscotch-common/src/helpers/new-codegen/har.ts b/packages/hoppscotch-common/src/helpers/new-codegen/har.ts index b66609768..787286284 100644 --- a/packages/hoppscotch-common/src/helpers/new-codegen/har.ts +++ b/packages/hoppscotch-common/src/helpers/new-codegen/har.ts @@ -8,6 +8,14 @@ import { FieldEquals, objectFieldIncludes } from "../typeutils" // Hoppscotch support HAR Spec 1.2 // For more info on the spec: http://www.softwareishard.com/blog/har-12-spec/ +const splitHarQueryParams = (sep: string) => { + return (s: string): Array => { + const out = pipe(s, S.split(sep)) + const [key, ...rest] = out + return [key, rest.join(sep)] // Split by the first colon and join the rest + } +} + const buildHarHeaders = (req: HoppRESTRequest): Har.Header[] => { return req.headers .filter((header) => header.active) @@ -43,7 +51,7 @@ const buildHarPostParams = ( flow( // Define how each lines are parsed - S.split(":"), // Split by ":" + splitHarQueryParams(":"), // Split by the first ":" RA.map(S.trim), // Remove trailing spaces in key/value begins and ends ([key, value]) => ({ // Convert into a proper key value definition