Old links: old usernames are matched case-blind (1,044 of the reconcile's 2,147 were mixed case and were skipped); a case clash points nowhere. e2e 124/124
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -581,9 +581,11 @@ const server = http.createServer(async (req, res) => {
|
||||
if (p === '/api/admin/oldrefs' && req.method === 'POST') {
|
||||
let b; try { b = JSON.parse((await readRaw(req, 4 * 1024 * 1024)).toString('utf8')); } catch (e) { return json(res, 400, { error: 'bad json' }); }
|
||||
if (!b || !b.oldrefs || typeof b.oldrefs !== 'object') return json(res, 400, { error: 'oldrefs object required' });
|
||||
const o = {}; for (const [k, v] of Object.entries(b.oldrefs)) if (/^[a-z0-9_.-]{2,40}$/.test(k) && NAME_RE.test(String(v))) o[k] = String(v);
|
||||
// old usernames are matched case-blind (the lookup lowercases); two old names that differ only in case point nowhere (a clash)
|
||||
const o = {}, clash = new Set(); for (const [k0, v] of Object.entries(b.oldrefs)) { const k = String(k0).toLowerCase(); if (!/^[a-z0-9_.-]{2,40}$/.test(k) || !NAME_RE.test(String(v))) continue; if (o[k] && o[k] !== String(v)) clash.add(k); o[k] = String(v); }
|
||||
for (const k of clash) delete o[k];
|
||||
fs.writeFileSync(path.join(C.dataDir, 'oldrefs.json'), JSON.stringify(o)); oldRefs = { at: 0, map: {} };
|
||||
return json(res, 200, { ok: true, total: Object.keys(o).length, skipped: Object.keys(b.oldrefs).length - Object.keys(o).length });
|
||||
return json(res, 200, { ok: true, total: Object.keys(o).length, skipped: Object.keys(b.oldrefs).length - Object.keys(o).length, clashes: clash.size });
|
||||
}
|
||||
// old YourProgramBuilder member programs as dormant packets (myheads.csv from the reconcile): {packets: [{oldId, oldUsername, hubId,
|
||||
// name, url, added}]}. Only people the hub knows (hubId). Nothing shows until the owner confirms it with a {id} link on My packets.
|
||||
|
||||
Reference in New Issue
Block a user