Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix(common): environment variable mapping when referencing other variables (#5704)
Aaron Fort Garcia254eb3c9582a
diff --git a/packages/hoppscotch-common/src/helpers/import-export/import/postman.ts b/packages/hoppscotch-common/src/helpers/import-export/import/postman.tsindex 1fbac662f..d07436332 100644--- a/packages/hoppscotch-common/src/helpers/import-export/import/postman.ts+++ b/packages/hoppscotch-common/src/helpers/import-export/import/postman.ts@@ -63,7 +63,7 @@ const getCollectionSchema = (jsonStr: string): string | null => {}}-const replacePMVarTemplating = flow(+export const replacePMVarTemplating = flow(S.replace(/{{\s*/g, "<<"),S.replace(/\s*}}/g, ">>"))diff --git a/packages/hoppscotch-common/src/helpers/import-export/import/postmanEnv.ts b/packages/hoppscotch-common/src/helpers/import-export/import/postmanEnv.tsindex fa8fca075..5c004e009 100644--- a/packages/hoppscotch-common/src/helpers/import-export/import/postmanEnv.ts+++ b/packages/hoppscotch-common/src/helpers/import-export/import/postmanEnv.ts@@ -6,6 +6,7 @@ import { z } from "zod"import { safeParseJSON } from "~/helpers/functional/json"import { IMPORTER_INVALID_FILE_FORMAT } from "."import { uniqueID } from "~/helpers/utils/uniqueID"+import { replacePMVarTemplating } from "./postman"const postmanEnvSchema = z.object({name: z.string(),@@ -56,8 +57,8 @@ export const postmanEnvImporter = (contents: string[]) => {name,variables: values.map(({ key, value, type }) => ({key,- initialValue: value,- currentValue: value,+ initialValue: replacePMVarTemplating(value),+ currentValue: replacePMVarTemplating(value),secret: type === "secret",})),})