From 4788813c3996e09e4d52c2cded318c0a8cd8bd34 Mon Sep 17 00:00:00 2001 From: abersheeran Date: Sat, 6 Jan 2024 10:08:16 +0800 Subject: [PATCH] Refactor content metadata handling in index.ts --- src/index.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3ba023a..f17579a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -151,28 +151,28 @@ async function handle_get(request: Request, bucket: R2Bucket): Promise ...(object.httpMetadata?.contentDisposition ? { - 'Content-Disposition': object.httpMetadata.contentDisposition, - } + 'Content-Disposition': object.httpMetadata.contentDisposition, + } : {}), ...(object.httpMetadata?.contentEncoding ? { - 'Content-Encoding': object.httpMetadata.contentEncoding, - } + 'Content-Encoding': object.httpMetadata.contentEncoding, + } : {}), ...(object.httpMetadata?.contentLanguage ? { - 'Content-Language': object.httpMetadata.contentLanguage, - } + 'Content-Language': object.httpMetadata.contentLanguage, + } : {}), ...(object.httpMetadata?.cacheControl ? { - 'Cache-Control': object.httpMetadata.cacheControl, - } + 'Cache-Control': object.httpMetadata.cacheControl, + } : {}), ...(object.httpMetadata?.cacheExpiry ? { - 'Cache-Expiry': object.httpMetadata.cacheExpiry.toISOString(), - } + 'Cache-Expiry': object.httpMetadata.cacheExpiry.toISOString(), + } : {}), }, }); @@ -305,9 +305,9 @@ function generate_propfind_response(object: R2Object | null): string { ${Object.entries(fromR2Object(object)) - .filter(([_, value]) => value !== undefined) - .map(([key, value]) => `<${key}>${value}`) - .join('\n ')} + .filter(([_, value]) => value !== undefined) + .map(([key, value]) => `<${key}>${value}`) + .join('\n ')} HTTP/1.1 200 OK