Properly fix empty body on GET/HEAD for CardDav/CalDav

Related to 47f443c300
This commit is contained in:
Bruno Bernardino
2025-08-28 17:48:10 +01:00
parent 47f443c300
commit f14c40d05d
3 changed files with 5 additions and 5 deletions

View File

@@ -31,14 +31,14 @@ export const handler: Handler<Data, FreshContextState> = async (request, context
const requestBodyText = await request.clone().text();
// Remove the `/caldav/` prefix from the hrefs in the request
let parsedRequestBodyText = requestBodyText.replaceAll('<href>/caldav/', `<href>/`).replaceAll(
let parsedRequestBodyText: string | undefined = requestBodyText.replaceAll('<href>/caldav/', `<href>/`).replaceAll(
':href>/caldav/',
`:href>/`,
);
// The spec doesn't allow a body for GET or HEAD requests (and Deno fails if you try)
if (request.method === 'GET' || request.method === 'HEAD') {
parsedRequestBodyText = '';
parsedRequestBodyText = undefined;
}
const response = await fetch(`${calendarConfig.calDavUrl}/${path}`, {