fix: fix webdav sync issue
This commit is contained in:
parent
6aaf83f3c2
commit
99aa064319
|
@ -11,11 +11,11 @@ async function handle(
|
||||||
const fileName = `${folder}/backup.json`;
|
const fileName = `${folder}/backup.json`;
|
||||||
|
|
||||||
const requestUrl = new URL(req.url);
|
const requestUrl = new URL(req.url);
|
||||||
const endpoint = requestUrl.searchParams.get("endpoint");
|
let endpoint = requestUrl.searchParams.get("endpoint");
|
||||||
|
if (!endpoint?.endsWith("/")) {
|
||||||
const [protocol, ...subpath] = params.path;
|
endpoint += "/";
|
||||||
|
}
|
||||||
const endpointPath = subpath.join("/");
|
const endpointPath = params.path.join("/");
|
||||||
|
|
||||||
// only allow MKCOL, GET, PUT
|
// only allow MKCOL, GET, PUT
|
||||||
if (req.method !== "MKCOL" && req.method !== "GET" && req.method !== "PUT") {
|
if (req.method !== "MKCOL" && req.method !== "GET" && req.method !== "PUT") {
|
||||||
|
@ -78,7 +78,7 @@ async function handle(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetUrl = `${protocol}://${endpoint + endpointPath}`;
|
const targetUrl = `${endpoint + endpointPath}`;
|
||||||
|
|
||||||
const method = req.method;
|
const method = req.method;
|
||||||
const shouldNotHaveBody = ["get", "head"].includes(
|
const shouldNotHaveBody = ["get", "head"].includes(
|
||||||
|
|
Loading…
Reference in New Issue