Skip to content

Commit

Permalink
fix #309
Browse files Browse the repository at this point in the history
Merge pull request #310 from dawn-lc/dev
  • Loading branch information
dawn-lc authored Mar 7, 2025
2 parents 3d77be3 + 16cbae2 commit 4f15505
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "iwaradownloadtool",
"displayName": "IwaraDownloadTool",
"version": "3.2.198",
"version": "3.2.199",
"private": true,
"type": "module",
"scripts": {
Expand Down
16 changes: 15 additions & 1 deletion src/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,21 @@ export class Path implements LocalPath {
const segments = path.split(/[\\/]/);
// 驱动器部分不检测,从第二段开始
for (let i = 1; i < segments.length; i++) {
if (invalidChars.test(segments[i])) {
let segment = segments[i];
let variables = [...segment.matchAll(/%#(.*?)#%/g)].map(match => {
let variable = match[1].split(':')
if (variable.length > 1) {
if (invalidChars.test(variable[1])) {
throw new Error(`路径变量格式化参数 "${variable[1]}" 含有非法字符`);
}
}
return match[1]
});
for (let index = 0; index < variables.length; index++) {
const variable = variables[index];
segment = segment.replaceAll(variable,'')
}
if (invalidChars.test(segment)) {
throw new Error(`路径段 "${segments[i]}" 含有非法字符`);
}
}
Expand Down

0 comments on commit 4f15505

Please sign in to comment.