diff --git a/packages/hoppscotch-app/src/helpers/import-export/import/hopp.ts b/packages/hoppscotch-app/src/helpers/import-export/import/hopp.ts index d8f7f84d..259ea59b 100644 --- a/packages/hoppscotch-app/src/helpers/import-export/import/hopp.ts +++ b/packages/hoppscotch-app/src/helpers/import-export/import/hopp.ts @@ -33,12 +33,7 @@ export default defineImporter({ O.chain( flow( makeCollectionsArray, - RA.map( - flow( - O.fromPredicate(isValidCollection), - O.map(translateToNewRESTCollection) - ) - ), + RA.map(validateCollection), O.sequenceArray, O.map(RA.toArray) ) @@ -61,6 +56,18 @@ const isValidCollection = ( ): collection is HoppCollection => isPlainObject(collection) && "v" in collection +/** + * checks if a collection is a valid hoppscotch collection. + * else translate it into one. + */ +const validateCollection = (collection: unknown) => { + if (isValidCollection(collection)) { + return O.some(collection) + } else { + return O.some(translateToNewRESTCollection(collection)) + } +} + /** * convert single collection object into an array so it can be handled the same as multiple collections */