fix: 接口测试保存校验URL正确性

This commit is contained in:
chenjianxing 2020-07-23 19:46:17 +08:00
parent e6479365a5
commit bb8571da2d
1 changed files with 17 additions and 4 deletions

View File

@ -283,10 +283,20 @@ export class HttpRequest extends Request {
info: 'api_test.request.input_path'
}
}
} else if (!this.url) {
return {
isValid: false,
info: 'api_test.request.input_url'
} else {
if (!this.url) {
return {
isValid: false,
info: 'api_test.request.input_url'
}
}
try {
new URL(this.url)
} catch (e) {
return {
isValid: false,
info: 'api_test.request.url_invalid'
}
}
}
return {
@ -631,6 +641,9 @@ class JMXHttpRequest {
this.useEnvironment = request.useEnvironment;
this.method = request.method;
if (!request.useEnvironment) {
if (!request.url.startsWith("http://") && !request.url.startsWith("https://")) {
request.url = 'http://' + request.url;
}
let url = new URL(request.url);
this.hostname = decodeURIComponent(url.hostname);
this.pathname = decodeURIComponent(url.pathname);