Changeset 834bcc3 in Klonkt for src/routes/linkbio.js
- Timestamp:
- 06/23/2026 06:14:27 PM (3 months ago)
- Branches:
- main
- Children:
- d774679
- Parents:
- bb42dfb
- File:
-
- 1 edited
-
src/routes/linkbio.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/linkbio.js
rbb42dfb r834bcc3 1 1 /** 2 * Link-in-bio + klikstats (premium feature #6).2 * Link-in-bio + click stats (premium feature #6). 3 3 * 4 * GET /links -> Linktree- achtige pagina met de profile_links van de site5 * GET /links/go/:i -> telt de klik (per url) en stuurt door naar de externeURL4 * GET /links -> Linktree-style page with the site's profile_links 5 * GET /links/go/:i -> counts the click (per url) and redirects to the external URL 6 6 * 7 * Hergebruikt de bestaande sites.profile_links (JSON [{platform,url}]) + de8 * PLATFORMS -iconen/labels. Klikken landen in link_clicks (zie /admin/stats).9 * Open-redirect -veilig: /links/go/:i stuurt ALLEEN door naar een url die in de10 * eigen profile_links staat. Hub: via /user/:slug/links.7 * Reuses the existing sites.profile_links (JSON [{platform,url}]) + the 8 * PLATFORMS icons/labels. Clicks are stored in link_clicks (see /admin/stats). 9 * Open-redirect safe: /links/go/:i ONLY redirects to a url present in the 10 * site's own profile_links. Hub: via /user/:slug/links. 11 11 */ 12 12 … … 48 48 if (!link || !link.url) return next(); 49 49 const url = String(link.url); 50 // Alleen externe http(s)- of mailto-links (geenopen redirect / javascript:).50 // Only external http(s) or mailto links (no open redirect / javascript:). 51 51 if (!/^https?:\/\//i.test(url) && !/^mailto:/i.test(url)) return res.status(400).send('Bad link'); 52 52 try { … … 55 55 ON CONFLICT(site_id, url) DO UPDATE SET clicks = clicks + 1, updated_at = CURRENT_TIMESTAMP` 56 56 ).run(site.id, url); 57 } catch { /* telling mag de redirect nooit breken*/ }57 } catch { /* counting must never break the redirect */ } 58 58 res.redirect(302, url); 59 59 });
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)