Skip to content

Commit

Permalink
文件名的特殊字符在下载任务创建阶段修复
Browse files Browse the repository at this point in the history
  • Loading branch information
chenhb23 committed Jan 21, 2024
1 parent 9add405 commit 295571c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function restoreFileName(name: string) {

// 移除文件名的非法字符
export function fixFileName(name: string) {
if (!name) return name
return name.replace(/[\\/:*?"<>|]/g, '_')
}

Expand Down
4 changes: 3 additions & 1 deletion src/renderer/store/task/DownloadTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export class DownloadTask implements BaseTask {
})
// Object.assign(this, {uid: `${Date.now()}`}, props)
Object.assign(this, props)
if (props.name) {
this.name = fixFileName(props.name)
}
}

get total() {
Expand Down Expand Up @@ -110,7 +113,6 @@ export class DownloadTask implements BaseTask {
if (!this.name) {
this.name = name
}
this.name = fixFileName(this.name)
if (this.urlType === URLType.file && isSpecificFile(name)) {
this.name = restoreFileName(this.name)
}
Expand Down

0 comments on commit 295571c

Please sign in to comment.