Bare /join: honour ?ref= before the sponsor cookie

This commit is contained in:
martbost
2026-10-11 18:29:22 -05:00
parent 041a3d41ae
commit b796a7a64e
+2 -1
View File
@@ -1748,7 +1748,8 @@ const server = http.createServer(async (req, res) => {
// "Not found"): send the visitor to the sponsored join page. ?ref= has already been folded into the iap.sponsor cookie by
// the viral-link handler above, so the cookie decides; nobody known -> the company position, like the partner kit.
if ((p === '/join' || p === '/join/') && (req.method === 'GET' || req.method === 'HEAD')) {
const spon = String(parseCookies(req)['iap.sponsor'] || '').toLowerCase().replace(/[^a-z0-9_]/g, '').slice(0, 20);
const clean = s => String(s || '').toLowerCase().replace(/[^a-z0-9_]/g, '').slice(0, 20);
const refQ = clean(u.searchParams.get('ref')); const spon = (refQ && (JOIN_ALIASES[refQ] || refQ)) || clean(parseCookies(req)['iap.sponsor']); // ?ref= wins, then the cookie
u.searchParams.delete('ref'); const qs = u.searchParams.toString();
res.writeHead(302, baseHeaders({ Location: '/join/' + (spon || 'company') + (qs ? '?' + qs : ''), 'Cache-Control': 'no-store' })); return res.end();
}