From 19703d1f68e18cf6556ed55e422505b253de6fd9 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 26 Jan 2021 14:15:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=BF=AB=E6=8D=B7=E8=B0=83?= =?UTF-8?q?=E8=AF=95=EF=BC=8Curl=E5=8F=82=E6=95=B0=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/debug/DebugHttpPage.vue | 33 +++++++++++++++++-- .../business/components/api/test/Upgrade.vue | 1 - 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue index 7bef849ff2..39d0243fb7 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue @@ -7,7 +7,7 @@ + class="ms-http-input" size="small" :disabled="testCase!=undefined" @blur="urlChange"> @@ -55,6 +55,7 @@ import {REQ_METHOD} from "../../model/JsonData"; import MsRequestResultTail from "../response/RequestResultTail"; import MsJmxStep from "../step/JmxStep"; + import {KeyValue} from "../../model/ApiTestModel"; export default { name: "ApiConfig", @@ -167,7 +168,35 @@ return false; } }) - } + }, + urlChange() { + if (!this.debugForm.url || this.debugForm.url.indexOf('?') === -1) return; + let url = this.getURL(this.addProtocol(this.debugForm.url)); + if (url) { + this.debugForm.url = decodeURIComponent(this.debugForm.url.substr(0, this.debugForm.url.indexOf("?"))); + } + }, + addProtocol(url) { + if (url) { + if (!url.toLowerCase().startsWith("https") && !url.toLowerCase().startsWith("http")) { + return "https://" + url; + } + } + return url; + }, + getURL(urlStr) { + try { + let url = new URL(urlStr); + url.searchParams.forEach((value, key) => { + if (key && value) { + this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value})); + } + }); + return url; + } catch (e) { + this.$error(this.$t('api_test.request.url_invalid'), 2000); + } + }, } } diff --git a/frontend/src/business/components/api/test/Upgrade.vue b/frontend/src/business/components/api/test/Upgrade.vue index 354b7c785d..51149c0843 100644 --- a/frontend/src/business/components/api/test/Upgrade.vue +++ b/frontend/src/business/components/api/test/Upgrade.vue @@ -98,7 +98,6 @@ this.$warning("请选择一个模块"); return; } - console.log(this.currentModule) if (this.currentModule.id === "root") { this.$warning("不能选默认模块,请重新选择一个模块"); return;