fix(接口自动化): 请求路径校验

This commit is contained in:
fit2-zhao 2020-12-18 10:54:49 +08:00
parent 3db39fb276
commit 75eeae71de
4 changed files with 9 additions and 12 deletions

View File

@ -100,13 +100,18 @@
name: "MsAddCompleteHttpApi", name: "MsAddCompleteHttpApi",
components: {MsResponseText, MsApiRequestForm, MsJsr233Processor}, components: {MsResponseText, MsApiRequestForm, MsJsr233Processor},
data() { data() {
let validateURL = (rule, value, callback) => {
if (!this.httpForm.path.startsWith("/") || this.httpForm.path.match(/\s/) != null) {
callback(this.$t('api_test.definition.request.path_valid_info'));
}
};
return { return {
rule: { rule: {
name: [ name: [
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'}, {required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'} {max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
], ],
path: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}], path: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}, {validator: validateURL, trigger: 'blur'}],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}], userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
moduleId: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}], moduleId: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}], status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
@ -124,10 +129,6 @@
runTest() { runTest() {
this.$refs['httpForm'].validate((valid) => { this.$refs['httpForm'].validate((valid) => {
if (valid) { if (valid) {
if(this.httpForm.path.match(/\s/)!=null){
this.$error(this.$t("api_test.definition.request.path_valid_info"));
return false;
}
this.setParameter(); this.setParameter();
this.$emit('runTest', this.httpForm); this.$emit('runTest', this.httpForm);
} else { } else {
@ -150,10 +151,6 @@
saveApi() { saveApi() {
this.$refs['httpForm'].validate((valid) => { this.$refs['httpForm'].validate((valid) => {
if (valid) { if (valid) {
if(this.httpForm.path.match(/\s/)!=null){
this.$error(this.$t("api_test.definition.request.path_valid_info"));
return false;
}
this.setParameter(); this.setParameter();
this.$emit('saveApi', this.httpForm); this.$emit('saveApi', this.httpForm);
} }

View File

@ -543,7 +543,7 @@ export default {
create_info: 'Create', create_info: 'Create',
update_info: 'Update', update_info: 'Update',
batch_edit: "Batch edit", batch_edit: "Batch edit",
path_valid_info: "The request address cannot contain spaces", path_valid_info: "The request path is invalid",
} }
}, },
automation: { automation: {

View File

@ -542,7 +542,7 @@ export default {
create_info: '创建', create_info: '创建',
update_info: '更新', update_info: '更新',
batch_edit: "批量编辑", batch_edit: "批量编辑",
path_valid_info: "请求地址不能包含空格", path_valid_info: "请求路径无效",
} }
}, },
automation: { automation: {

View File

@ -542,7 +542,7 @@ export default {
create_info: '創建', create_info: '創建',
update_info: '更新', update_info: '更新',
batch_edit: "批量編輯", batch_edit: "批量編輯",
path_valid_info: "請求地址不能包含空格", path_valid_info: "請求路径无效",
} }
}, },
automation: { automation: {