From 21987a9501dc9319596eade3b9512e64f20d7912 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Fri, 22 Mar 2024 13:46:52 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20Add=20`url`=20param=20to?= =?UTF-8?q?=20sandbox=20(#15)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- theme/app/routes/sandbox.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/theme/app/routes/sandbox.tsx b/theme/app/routes/sandbox.tsx index 62a4a23..c465e12 100644 --- a/theme/app/routes/sandbox.tsx +++ b/theme/app/routes/sandbox.tsx @@ -48,8 +48,15 @@ export const loader: LoaderFunction = async ({ request }) => { const url = new URL(request.url); const myst = url.searchParams.get('myst'); const tab = url.searchParams.get('tab'); - - const data = myst ? fromBinary(atob(myst)) : undefined; + const srcURL = url.searchParams.get("url"); + + let data; + if (srcURL) { + const response = await fetch(srcURL); + data = await response.text(); + } else { + data = myst ? fromBinary(atob(myst)) : undefined; + } return json({ data, tab }); };