MCPcopy
hub / github.com/unpkg/unpkg / redirect

Function redirect

packages/unpkg-app/src/request-handler.tsx:123–141  ·  view source on GitHub ↗
(location: string | URL, init?: ResponseInit | number)

Source from the content-addressed store, hash-verified

121}
122
123function redirect(location: string | URL, init?: ResponseInit | number): Response {
124 if (typeof init === "number") {
125 return new Response(`Redirecting to ${location}`, {
126 status: init,
127 headers: {
128 Location: location.toString(),
129 },
130 });
131 }
132
133 return new Response(`Redirecting to ${location}`, {
134 status: 302,
135 ...init,
136 headers: {
137 Location: location.toString(),
138 ...init?.headers,
139 },
140 });
141}
142
143async function renderPage(env: Env, node: VNode, init?: ResponseInit): Promise<Response> {
144 let assetsManifest = await loadAssetsManifest(env);

Callers 1

handleRequestFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected