From ac5ff17af5cdfed1cef78327e2b4da21012442e4 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Fri, 29 Oct 2021 16:16:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=87=AA=E5=AE=9A=E4=B9=89=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=89=87=E6=AE=B5):=20=E4=BB=8EAPI=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=EF=BC=8C=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84=E8=84=9A=E6=9C=AC=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1007475 --user=lyh 【接口测试】前置脚本-从API定义导入,自动生成的脚本报错了 https://www.tapd.cn/55049933/s/1061715 --- .../project/menu/function/custom-function.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/frontend/src/business/components/project/menu/function/custom-function.js b/frontend/src/business/components/project/menu/function/custom-function.js index 1eab9b5255..9902b240fa 100644 --- a/frontend/src/business/components/project/menu/function/custom-function.js +++ b/frontend/src/business/components/project/menu/function/custom-function.js @@ -143,11 +143,10 @@ function _beanshellTemplate(obj) { let {requestHeaders = new Map(), requestBody = "", requestPath = "/", requestMethod = "GET", protocol = "http", requestArguments = new Map(), domain = "", port = ""} = obj; let uri = `new URIBuilder() - .setScheme("${protocol}") - .setHost("${domain}") - .setPort(${port}) // int类型端口 - .setPath("${requestPath}") - `; + .setScheme("${protocol}") + .setHost("${domain}") + .setPath("${requestPath}") + `; // http 请求类型 let method = requestMethod.toLowerCase().replace(/^\S/, s => s.toUpperCase()); let httpMethodCode = `Http${method} request = new Http${method}(uri);`; @@ -155,7 +154,15 @@ function _beanshellTemplate(obj) { for (let [k, v] of requestArguments) { uri = uri + `.setParameter("${k}", "${v}")`; } - uri = uri + ".build();"; + if (port) { + uri += `.setPort(${port}) // int类型端口 + `; + uri += ` .build();`; + } else { + uri += `// .setPort(${port}) // int类型端口 + `; + uri += ` .build();`; + } // 设置请求头 let setHeader = ""; for (let [k, v] of requestHeaders) {