From 5f3a7754d5988bf21fb48c271b89f600bfeeb8ce Mon Sep 17 00:00:00 2001 From: Anwarul Islam Date: Wed, 19 Mar 2025 14:20:03 +0600 Subject: [PATCH] fix(common): handle missing host and basePath in OpenAPI URL parsing (#4908) Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com> --- .../src/helpers/import-export/import/openapi.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts b/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts index 2678389d..1d4516ed 100644 --- a/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts +++ b/packages/hoppscotch-common/src/helpers/import-export/import/openapi.ts @@ -745,7 +745,9 @@ const parseOpenAPIUrl = ( **/ if (objectHasProperty(doc, "swagger")) { - return `${doc.host}${doc.basePath}` + const { host = "<>", basePath = "" } = + doc satisfies OpenAPIV2.Document + return `${host}${basePath}` } /**