mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-07-12 18:43:45 +00:00
refactor(#89): Address PR comments
This commit is contained in:
@@ -18,10 +18,21 @@ export const PUT = async (event: RequestEvent) => {
|
||||
await event.locals.supabase.auth.setSession(session);
|
||||
}
|
||||
|
||||
const body = (await event.request.json()) as {
|
||||
let body: {
|
||||
folderId?: string | null;
|
||||
path?: string | null;
|
||||
};
|
||||
try {
|
||||
body = (await event.request.json()) as {
|
||||
folderId?: string | null;
|
||||
path?: string | null;
|
||||
};
|
||||
} catch (err) {
|
||||
if (err instanceof SyntaxError) {
|
||||
return new Response('Malformed JSON', { status: 400 });
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
const patch: Record<string, unknown> = {};
|
||||
if (body.folderId !== undefined) patch.folderId = body.folderId;
|
||||
|
||||
@@ -13,7 +13,9 @@ export const GET = async (event: RequestEvent) => {
|
||||
const path = url.searchParams.get('path');
|
||||
const returnToRaw = url.searchParams.get('returnTo');
|
||||
const returnTo =
|
||||
returnToRaw && returnToRaw.startsWith('/') ? returnToRaw : '/backup-settings';
|
||||
returnToRaw && returnToRaw.startsWith('/') && !returnToRaw.startsWith('//')
|
||||
? returnToRaw
|
||||
: '/backup-settings';
|
||||
|
||||
if (pokedexId) {
|
||||
const { session } = await event.locals.safeGetSession();
|
||||
|
||||
@@ -13,7 +13,9 @@ export const GET = async (event: RequestEvent) => {
|
||||
const folderId = url.searchParams.get('folderId');
|
||||
const returnToRaw = url.searchParams.get('returnTo');
|
||||
const returnTo =
|
||||
returnToRaw && returnToRaw.startsWith('/') ? returnToRaw : '/backup-settings';
|
||||
returnToRaw && returnToRaw.startsWith('/') && !returnToRaw.startsWith('//')
|
||||
? returnToRaw
|
||||
: '/backup-settings';
|
||||
|
||||
if (pokedexId) {
|
||||
const { session } = await event.locals.safeGetSession();
|
||||
|
||||
Reference in New Issue
Block a user