🐛 添加 shareurl 解码的错误处理

- 添加try-catch块以处理decodeURIComponent函数中的潜在错误
This commit is contained in:
Cp0204 2024-12-05 16:50:26 +08:00
parent 7d8701db0a
commit c90262485f

View File

@ -524,11 +524,16 @@
changeShareurl(task) { changeShareurl(task) {
if (!task.shareurl) if (!task.shareurl)
return; return;
this.$set(task, "shareurl_ban", undefined);
// 从URL中提取任务名 // 从URL中提取任务名
const matches = decodeURIComponent(task.shareurl).match(/\/(\w{32})-([^\/]+)$/); try {
if (matches) { const matches = decodeURIComponent(task.shareurl).match(/\/(\w{32})-([^\/]+)$/);
task.taskname = task.taskname == "" ? matches[2] : task.taskname; if (matches) {
task.savepath = task.savepath.replace(/TASKNAME/g, matches[2]); task.taskname = task.taskname == "" ? matches[2] : task.taskname;
task.savepath = task.savepath.replace(/TASKNAME/g, matches[2]);
}
} catch (e) {
console.error("Error decodeURIComponent:", e);
} }
// 从分享中提取任务名 // 从分享中提取任务名
axios.get('/get_share_detail', { params: { shareurl: task.shareurl } }) axios.get('/get_share_detail', { params: { shareurl: task.shareurl } })