({ request, context })
| 70 | }; |
| 71 | |
| 72 | export let loader: LoaderFunction = async ({ request, context }) => { |
| 73 | const url = new URL(request.url); |
| 74 | const jsonUrl = url.searchParams.get("jsonUrl"); |
| 75 | |
| 76 | if (!jsonUrl) { |
| 77 | return redirect("/"); |
| 78 | } |
| 79 | |
| 80 | const jsonURL = new URL(jsonUrl); |
| 81 | |
| 82 | invariant(jsonURL, "jsonUrl must be a valid URL"); |
| 83 | |
| 84 | const doc = await createFromUrl(jsonURL, jsonURL.href); |
| 85 | |
| 86 | context.waitUntil( |
| 87 | sendEvent({ |
| 88 | type: "create", |
| 89 | from: "url", |
| 90 | hostname: jsonURL.hostname, |
| 91 | id: doc.id, |
| 92 | source: url.searchParams.get("utm_source") ?? url.hostname, |
| 93 | }) |
| 94 | ); |
| 95 | |
| 96 | return redirect(`/j/${doc.id}`); |
| 97 | }; |
nothing calls this directly
no test coverage detected