From 254eb3c9582abcf111fd620ae37f67c407b555bd Mon Sep 17 00:00:00 2001 From: Aaron Fort Garcia Date: Wed, 14 Jan 2026 08:42:16 +0100 Subject: [PATCH] fix(common): environment variable mapping when referencing other variables (#5704) --- .../src/helpers/import-export/import/postman.ts | 2 +- .../src/helpers/import-export/import/postmanEnv.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/hoppscotch-common/src/helpers/import-export/import/postman.ts b/packages/hoppscotch-common/src/helpers/import-export/import/postman.ts index 1fbac662..d0743633 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.ts index fa8fca07..5c004e00 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", })), })