From a9292eed9ef1b42e4a96e863218ed5a69a4284ae Mon Sep 17 00:00:00 2001 From: liyasthomas Date: Thu, 23 Dec 2021 13:04:47 +0530 Subject: [PATCH] fix: collection parser for hopp importer --- .../components/collections/ImportExport.vue | 18 +++++++++++++++++- .../helpers/import-export/import/hopp.ts | 7 +++++-- .../helpers/import-export/import/index.ts | 2 +- packages/hoppscotch-app/locales/en.json | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/hoppscotch-app/components/collections/ImportExport.vue b/packages/hoppscotch-app/components/collections/ImportExport.vue index 542336983..6ed7c0355 100644 --- a/packages/hoppscotch-app/components/collections/ImportExport.vue +++ b/packages/hoppscotch-app/components/collections/ImportExport.vue @@ -156,6 +156,7 @@ diff --git a/packages/hoppscotch-app/helpers/import-export/import/hopp.ts b/packages/hoppscotch-app/helpers/import-export/import/hopp.ts index bd7877c06..66be98062 100644 --- a/packages/hoppscotch-app/helpers/import-export/import/hopp.ts +++ b/packages/hoppscotch-app/helpers/import-export/import/hopp.ts @@ -8,10 +8,13 @@ import { translateToNewRESTCollection, } from "~/newstore/collections" -const importer: HoppImporter> = (content) => +const importer: HoppImporter[]> = (content) => pipe( E.tryCatch( - () => translateToNewRESTCollection(content), + () => + JSON.parse(content).map((coll: any) => + translateToNewRESTCollection(coll) + ), () => IMPORTER_INVALID_FILE_FORMAT ), TE.fromEither diff --git a/packages/hoppscotch-app/helpers/import-export/import/index.ts b/packages/hoppscotch-app/helpers/import-export/import/index.ts index 090c23f03..239d06052 100644 --- a/packages/hoppscotch-app/helpers/import-export/import/index.ts +++ b/packages/hoppscotch-app/helpers/import-export/import/index.ts @@ -30,7 +30,7 @@ export type HoppImporterDefintion = { } export const RESTCollectionImporters: HoppImporterDefintion< - Collection + Collection[] >[] = [ { name: "Hoppscotch REST Collection", diff --git a/packages/hoppscotch-app/locales/en.json b/packages/hoppscotch-app/locales/en.json index 44ed5f82b..9efd1bbfc 100644 --- a/packages/hoppscotch-app/locales/en.json +++ b/packages/hoppscotch-app/locales/en.json @@ -236,7 +236,7 @@ "from_postman": "Import from Postman", "from_url": "Import from URL", "gist_url": "Enter Gist URL", - "json": "Import from JSON", + "json": "Import from file", "title": "Import" }, "layout": {