mirror of
https://github.com/4ev-link/4ev.link.git
synced 2026-01-14 08:38:39 +00:00
Feat: Return analytics status along with destination
This commit is contained in:
@@ -7,7 +7,10 @@ export async function onRequestGet({ request, env }) {
|
|||||||
const dest = await env.KV_EV.get(slug);
|
const dest = await env.KV_EV.get(slug);
|
||||||
if (!dest) return new Response("Link not found", { status: 404 });
|
if (!dest) return new Response("Link not found", { status: 404 });
|
||||||
|
|
||||||
return Response.json({ destination_url: dest });
|
const analytics_enabled = dest.startsWith('✺');
|
||||||
|
const destination_url = analytics_enabled ? dest.substring(1) : dest;
|
||||||
|
|
||||||
|
return Response.json({ destination_url, analytics_enabled });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return new Response(e.message, { status: 500 });
|
return new Response(e.message, { status: 500 });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user