diff --git a/api-test/frontend/src/business/automation/report/ApiReportDetail.vue b/api-test/frontend/src/business/automation/report/ApiReportDetail.vue index f5b7655ff6..f81ec557d6 100644 --- a/api-test/frontend/src/business/automation/report/ApiReportDetail.vue +++ b/api-test/frontend/src/business/automation/report/ApiReportDetail.vue @@ -695,6 +695,7 @@ export default { this.reportExportVisible = true; let reset = this.exportReportReset; let name = this.report.name; + name = this.encodeSearchKey(name); this.$nextTick(() => { setTimeout(() => { downloadPDF(document.getElementById('apiTestReport'), name || 'scenario-report'); @@ -702,6 +703,38 @@ export default { }, 5000); }); }, + // 对报告名称中的特殊字符进行编码 + encodeSearchKey(key) { + const encodeArr = [ + { + code: '%', + encode: '%25', + }, + { + code: '?', + encode: '%3F', + }, + { + code: '#', + encode: '%23', + }, + { + code: '&', + encode: '%26', + }, + { + code: '=', + encode: '%3D', + }, + ]; + return key.replace(/[%?#&=]/g, ($, index, str) => { + for (const k of encodeArr) { + if (k.code === $) { + return k.encode; + } + } + }); + }, handleSave() { if (!this.report.name) { this.$warning(this.$t('api_test.automation.report_name_info'));