From 72dd818def6c8059b68b42830975fdaf7c9dc2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Sun, 22 Jan 2023 20:43:36 +0100 Subject: [PATCH] Change ETag to the latest snapshot's ID --- src/pages/playlists/[playlistId]/snapshots.json.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/playlists/[playlistId]/snapshots.json.ts b/src/pages/playlists/[playlistId]/snapshots.json.ts index b9cdd98..87f1583 100644 --- a/src/pages/playlists/[playlistId]/snapshots.json.ts +++ b/src/pages/playlists/[playlistId]/snapshots.json.ts @@ -49,7 +49,7 @@ export const get: APIRoute = async ({ request, params }) => { }) ); - const body = JSON.stringify( + const payload = queryParams.get('allowDuplicates') === 'yes' ? possiblyDuplicateSnapshots : // Since commits are sorted by the latest dateCaptured first, @@ -62,8 +62,10 @@ export const get: APIRoute = async ({ request, params }) => { snapshot ]) ).values() - ] - ); + ]; + + const body = JSON.stringify(payload); + const ETag = payload[0].snapshotId; const cacheControlDirectives = Date.now() > untilDate.getTime() @@ -75,7 +77,7 @@ export const get: APIRoute = async ({ request, params }) => { headers: { 'Content-Type': 'application/json;charset=utf-8', 'Cache-Control': `public, ${cacheControlDirectives}`, - ETag: etag as string + ETag } }); } catch (error) {