fix: har importing support base64 content

This commit is contained in:
jason 2018-09-13 14:30:55 +08:00
parent 5a20585704
commit 5717da4301
9 changed files with 18 additions and 4 deletions

View File

@ -1,5 +1,6 @@
const Mock = require('mockjs');
const filter = require('./power-string.js').filter;
const stringUtils = require('./power-string.js').utils;
const json5 = require('json5');
const Ajv = require('ajv');
/**
@ -168,6 +169,14 @@ function isJson(json) {
exports.isJson = isJson;
exports.unbase64 = function(base64Str) {
try {
return stringUtils.unbase64(base64Str);
} catch (err) {
return base64Str;
}
};
exports.json_parse = function(json) {
try {
return JSON.parse(json);

View File

@ -1,7 +1,7 @@
import { message } from 'antd';
import URL from 'url';
const GenerateSchema = require('generate-schema/src/schemas/json.js');
import { json_parse } from '../../common/utils.js';
import { json_parse, unbase64 } from '../../common/utils.js';
const transformJsonToSchema = json => {
json = json || {};
@ -199,7 +199,12 @@ function postman(importDataModule) {
res[item] = 'json';
} else if (item === 'res_body') {
res.res_body_is_json_schema = true;
res[item] = transformJsonToSchema(data.response.content.text);
if (data.response.content.encoding && data.response.content.encoding == 'base64') {
//base64
res[item] = transformJsonToSchema(unbase64(data.response.content.text));
} else {
res[item] = transformJsonToSchema(data.response.content.text);
}
} else {
res[item] = data.request[reflect[item]];
}

View File

@ -1 +1 @@
window.WEBPACK_ASSETS = {"index.js":{"js":"index@b3ae4e13fce6ebc01302.js","css":"index@b3ae4e13fce6ebc01302.css"},"lib":{"js":"lib@250ff659130357ed53a3.js"},"lib2":{"js":"lib2@dd0309d1dda071c015ba.js"},"lib3":{"js":"lib3@117a77c58de265bbb1ec.js"},"manifest":{"js":"manifest@f2f4bd774d6c221b3d5f.js"}}
window.WEBPACK_ASSETS = {"index.js":{"js":"index@841cead422a517b69145.js","css":"index@841cead422a517b69145.css"},"lib":{"js":"lib@250ff659130357ed53a3.js"},"lib2":{"js":"lib2@dd0309d1dda071c015ba.js"},"lib3":{"js":"lib3@117a77c58de265bbb1ec.js"},"manifest":{"js":"manifest@f2f4bd774d6c221b3d5f.js"}}

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long