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: allow single collections to imported by hopp importer

Andrew Bastin85521b4c37cf
diff --git a/packages/hoppscotch-app/helpers/import-export/import/hopp.ts b/packages/hoppscotch-app/helpers/import-export/import/hopp.ts
index 551799560..29f741770 100644
--- a/packages/hoppscotch-app/helpers/import-export/import/hopp.ts
+++ b/packages/hoppscotch-app/helpers/import-export/import/hopp.ts
@@ -20,10 +20,13 @@ export default defineImporter({
importer: ([content]) =>
pipe(
E.tryCatch(
- () =>
- JSON.parse(content).map((coll: any) =>
- translateToNewRESTCollection(coll)
- ),
+ () => {
+ const x = JSON.parse(content)
+
+ return Array.isArray(x)
+ ? x.map((coll: any) => translateToNewRESTCollection(coll))
+ : [translateToNewRESTCollection(x)]
+ },
() => IMPORTER_INVALID_FILE_FORMAT
),
TE.fromEither