Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: prevent unwanted variable wrapping during Insomnia import (#4076)

Anwarul Islamd45f15e9cb55
diff --git a/packages/hoppscotch-common/src/helpers/import-export/import/insomnia.ts b/packages/hoppscotch-common/src/helpers/import-export/import/insomnia.ts
index a69dbb9c3..a3781ad53 100644
--- a/packages/hoppscotch-common/src/helpers/import-export/import/insomnia.ts
+++ b/packages/hoppscotch-common/src/helpers/import-export/import/insomnia.ts
@@ -48,8 +48,13 @@ const parseInsomniaDoc = (content: string) =>
const replacePathVarTemplating = (expression: string) =>
expression.replaceAll(/:([^/]+)/g, "<<$1>>")
-const replaceVarTemplating = (expression: string) =>
- pipe(expression, replacePathVarTemplating, replaceInsomniaTemplating)
+const replaceVarTemplating = (expression: string, pathVar = false) => {
+ return pipe(
+ expression,
+ pathVar ? replacePathVarTemplating : (x) => x,
+ replaceInsomniaTemplating
+ )
+}
const getFoldersIn = (
folder: InsomniaFolderResource | null,
@@ -208,7 +213,7 @@ const getHoppRequest = (req: InsomniaRequestResource): HoppRESTRequest =>
makeRESTRequest({
name: req.name ?? "Untitled Request",
method: req.method?.toUpperCase() ?? "GET",
- endpoint: replaceVarTemplating(req.url ?? ""),
+ endpoint: replaceVarTemplating(req.url ?? "", true),
auth: getHoppReqAuth(req),
body: getHoppReqBody(req),
headers: getHoppReqHeaders(req),