From 99aa064319991b6ee53eb9c75bcfeb5a6b0188cb Mon Sep 17 00:00:00 2001 From: Fred Date: Thu, 14 Mar 2024 01:58:25 +0800 Subject: [PATCH] fix: fix webdav sync issue --- app/api/webdav/[...path]/route.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/api/webdav/[...path]/route.ts b/app/api/webdav/[...path]/route.ts index 826e2df01..c60ca18bb 100644 --- a/app/api/webdav/[...path]/route.ts +++ b/app/api/webdav/[...path]/route.ts @@ -11,11 +11,11 @@ async function handle( const fileName = `${folder}/backup.json`; const requestUrl = new URL(req.url); - const endpoint = requestUrl.searchParams.get("endpoint"); - - const [protocol, ...subpath] = params.path; - - const endpointPath = subpath.join("/"); + let endpoint = requestUrl.searchParams.get("endpoint"); + if (!endpoint?.endsWith("/")) { + endpoint += "/"; + } + const endpointPath = params.path.join("/"); // only allow MKCOL, GET, 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 shouldNotHaveBody = ["get", "head"].includes(