UNPKG

insomnia-importers

Version:

Various data importers for Insomnia

36 lines 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convert = exports.description = exports.name = exports.id = void 0; exports.id = 'insomnia-2'; exports.name = 'Insomnia v2'; exports.description = 'Insomnia export format 2'; const convert = rawData => { var _a, _b; let data = null; try { data = JSON.parse(rawData); } catch (error) { return null; } if (data.__export_format !== 2) { // Exit early if it's not the legacy format return null; } // The only difference between 2 and 3 is the request body object for (const resource of data.resources) { if (resource._type !== 'request') { continue; } // Convert old String request bodies to new (HAR) schema const contentTypeHeader = (_a = resource.headers) === null || _a === void 0 ? void 0 : _a.find(({ name }) => name.toLowerCase() === 'content-type'); const mimeType = (_b = contentTypeHeader === null || contentTypeHeader === void 0 ? void 0 : contentTypeHeader.value.split(';')[0]) !== null && _b !== void 0 ? _b : ''; resource.body = { mimeType, text: resource.body, }; } return data.resources; }; exports.convert = convert; //# sourceMappingURL=insomnia-2.js.map