Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nodejs module import bug in postmanLib.crossRequest. #2666

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions common/postmanLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,9 @@ function sandboxByBrowser(context = {}, script) {
* @param {*} preScript
* @param {*} afterScript
* @param {*} commonContext 负责传递一些业务信息,crossRequest 不关注具体传什么,只负责当中间人
* @param {*} commonContext 传导 pre-script 的 Enable 标记,适用于Server
*/
async function crossRequest(defaultOptions, preScript, afterScript, commonContext = {}) {
async function crossRequest(defaultOptions, preScript, afterScript, commonContext = {}, scriptEnable = true) {
let options = Object.assign({}, defaultOptions);
const taskId = options.taskId || Math.random() + '';
let urlObj = URL.parse(options.url, true),
Expand Down Expand Up @@ -300,12 +301,6 @@ async function crossRequest(defaultOptions, preScript, afterScript, commonContex
axios: axios
});

let scriptEnable = false;
try {
const yapi = require('../server/yapi');
scriptEnable = yapi.WEBCONFIG.scriptEnable === true;
} catch (err) {}

if (preScript && scriptEnable) {
context = await sandbox(context, preScript);
defaultOptions.url = options.url = URL.format({
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class openController extends baseController {
this.getUid(),
interfaceData.project_id,
interfaceData.interface_id
));
), yapi.WEBCONFIG.scriptEnable === true);
let res = data.res;

result = Object.assign(result, {
Expand Down