From 342b586ab934ba6e8444344518c1bdce95ca8bcc Mon Sep 17 00:00:00 2001 From: Luca Bosin Date: Mon, 28 Aug 2023 08:40:27 +0200 Subject: [PATCH] Remove JSON mode from download endpoint --- .../[slug]/[[timestamp]]/download/+server.ts | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/routes/[slug]/[[timestamp]]/download/+server.ts b/src/routes/[slug]/[[timestamp]]/download/+server.ts index cb518a0..ae2a662 100644 --- a/src/routes/[slug]/[[timestamp]]/download/+server.ts +++ b/src/routes/[slug]/[[timestamp]]/download/+server.ts @@ -4,7 +4,7 @@ import { error } from '@sveltejs/kit'; import fs from 'node:fs/promises'; import type { RequestHandler } from './$types'; -export const GET: RequestHandler = async ({ params, url }) => { +export const GET: RequestHandler = async ({ params }) => { try { const zipName = getZipName(params); const album = await getMetadata(zipName); @@ -12,22 +12,13 @@ export const GET: RequestHandler = async ({ params, url }) => { if (!allowDownload) { throw error(403, 'Forbidden'); } - if (url.searchParams.get('type') === 'json') { - return new Response(JSON.stringify(album), { - headers: { - 'Content-Type': 'application/json', - 'Content-Disposition': 'inline' - } - }); - } else { - const content = await fs.readFile(`./zip/${zipName}`); - return new Response(content, { - headers: { - 'Content-Type': 'application/zip', - 'Content-Disposition': `attachment; filename="${zipName}"` - } - }); - } + const content = await fs.readFile(`./zip/${zipName}`); + return new Response(content, { + headers: { + 'Content-Type': 'application/zip', + 'Content-Disposition': `attachment; filename="${zipName}"` + } + }); } catch (err) { throw error(404, 'Not found'); }