From 85521b4c37cfe8e018a6ff64188498785722e4d9 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 7 Feb 2022 23:39:18 +0530 Subject: [PATCH] fix: allow single collections to imported by hopp importer --- .../helpers/import-export/import/hopp.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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