Old referral links: check before the home page is served (/?<old username> was served as home)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-13 15:27:07 -06:00
parent 81c6123275
commit 7aa6bb6ed1
+7 -7
View File
@@ -234,6 +234,13 @@ const server = http.createServer(async (req, res) => {
// -- pages
if (req.method === 'GET' || req.method === 'HEAD') {
// old site links (2026-11-13): referral links were /?<old username> (bare query) and pages were *.php. An old username maps to
// the same person's network username (oldrefs.json, matched by email); a page address goes home.
if (/\.php$/i.test(p) || (p === '/' && /^[A-Za-z0-9_.-]{2,40}$/.test(u.search.slice(1).split('&')[0]))) { // "&fbclid=..." may follow
const old = /\.php$/i.test(p) && p !== '/index.php' ? '' : u.search.slice(1).split('&')[0].toLowerCase();
let OR = {}; try { OR = JSON.parse(fs.readFileSync(path.join(C.dataDir, 'oldrefs.json'), 'utf8')); } catch (e) {}
const net = old && OR[old]; res.writeHead(301, { Location: net ? '/?ref=' + encodeURIComponent(net) : '/', 'Cache-Control': 'no-store' }); return res.end();
}
const PAGES = { '/': 'index.html', '/board': 'board.html', '/join': 'join.html', '/my': 'my.html', '/how': 'how.html', '/ledger': 'ledger.html', '/contract': 'contract.html' };
if (PAGES[p]) {
const set = [];
@@ -259,13 +266,6 @@ const server = http.createServer(async (req, res) => {
const name = path.basename(p); if (!/^[a-z0-9-]+\.(png|jpg|gif)$/.test(name)) { res.writeHead(404); return res.end(); }
return sendFile(res, path.join(C.dataDir, 'art', name), { 'Cache-Control': 'public, max-age=86400' });
}
// old site links (2026-11-13): referral links were /?<old username> (bare query) and pages were *.php. An old username maps to
// the same person's network username (oldrefs.json, matched by email); a page address goes home.
if (/\.php$/i.test(p) || (p === '/' && /^[A-Za-z0-9_.-]{2,40}$/.test(u.search.slice(1).split('&')[0]))) { // "&fbclid=..." may follow
const old = /\.php$/i.test(p) && p !== '/index.php' ? '' : u.search.slice(1).split('&')[0].toLowerCase();
let OR = {}; try { OR = JSON.parse(fs.readFileSync(path.join(C.dataDir, 'oldrefs.json'), 'utf8')); } catch (e) {}
const net = old && OR[old]; res.writeHead(301, { Location: net ? '/?ref=' + encodeURIComponent(net) : '/', 'Cache-Control': 'no-store' }); return res.end();
}
const wm = /^\/w\/([a-z0-9]{8,16})$/.exec(p);
if (wm) {
const ok = !!WELCOME()[wm[1]];