fix(接口测试): 增加域名格式校验

This commit is contained in:
fit2-zhao 2020-10-20 15:32:58 +08:00
parent c44b72e5fa
commit 9d05edc6f4
1 changed files with 6 additions and 10 deletions

View File

@ -116,17 +116,13 @@
return true;
},
validateDomain(domain) {
let url = {};
try {
if (!domain.startsWith("http") || !domain.startsWith("https")) {
domain += "http://";
}
url = new URL(domain);
} catch (e) {
this.$warning(this.$t('load_test.input_domain'));
return false
let strRegex = "^(?=^.{3,255}$)(http(s)?:\\/\\/)?(www\\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\\d+)*(\\/\\w+\\.\\w+)*$";
const re = new RegExp(strRegex);
if (re.test(domain) && domain.length < 26) {
return true;
}
return true;
this.$warning(this.$t('load_test.input_domain'));
return false;
},
dblHostTable: function (row) {
row.status = 'edit';