fix(mount): stop double-encoding WebDAV paths
webdav lib encodePath already percent-encodes; our encodeURIComponent produced %25 and 400 on CJK/space paths.
This commit is contained in:
parent
a1483299f3
commit
a7a50f8d0a
|
|
@ -231,10 +231,13 @@ function describeWebdavError(e: unknown, path?: string): string {
|
||||||
return `连接失败:${short}`;
|
return `连接失败:${short}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** WebDAV 路径:补前导 /、去重斜杠、段级百分号编码(中文/空格) */
|
/**
|
||||||
|
* WebDAV 路径:只做斜杠规范化。
|
||||||
|
* 不要 encodeURIComponent —— webdav 库内部 encodePath 会再编码一次,
|
||||||
|
* 双重编码(% → %25)会导致服务器 400 Bad Request。
|
||||||
|
*/
|
||||||
function normalizeWebdavPath(input: string): string {
|
function normalizeWebdavPath(input: string): string {
|
||||||
const trimmed = input.trim() || "/";
|
const trimmed = (input || "/").trim().replace(/\\/g, "/");
|
||||||
const parts = trimmed.split("/").filter(Boolean);
|
const parts = trimmed.split("/").filter(Boolean);
|
||||||
const encoded = parts.map((seg) => encodeURIComponent(decodeURIComponent(seg)));
|
return parts.length ? `/${parts.join("/")}` : "/";
|
||||||
return `/${encoded.join("/")}`;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue