feat: add hostname substitution in user@host patterns
jsmith@macbook-pro now becomes ademo@mycomputer when both username and hostname are configured in the Identity tab. Hostnames are also caught standalone (e.g. just "macbook-pro" in text). Also rewrites README with detailed step-by-step Mozilla API key setup instructions for Firefox signing. https://claude.ai/code/session_01Dvgwe7XMoSxnWXkih8p1Cw
This commit is contained in:
+20
-3
@@ -186,15 +186,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Usernames + paths
|
||||
// Usernames + hostnames + paths
|
||||
if (id.enabled.usernames !== false) {
|
||||
const hostMap = new Map();
|
||||
for (const h of (id.hostnames || [])) {
|
||||
if (h.real && h.substitute) hostMap.set(h.real.toLowerCase(), h);
|
||||
}
|
||||
|
||||
for (const u of (id.usernames || [])) {
|
||||
if (!u.real || !u.substitute) continue;
|
||||
|
||||
// user@hostname
|
||||
// user@hostname (substitute both username and hostname if configured)
|
||||
result = result.replace(new RegExp(esc(u.real) + '@[a-zA-Z0-9._\\-]+', 'g'), (matched) => {
|
||||
const host = matched.slice(u.real.length + 1);
|
||||
const sub = u.substitute + '@' + host;
|
||||
const hostEntry = hostMap.get(host.toLowerCase());
|
||||
const subHost = hostEntry ? hostEntry.substitute : host;
|
||||
const sub = u.substitute + '@' + subHost;
|
||||
replacements.push({ original: matched, replaced: sub, category: 'username', pattern: 'smart' });
|
||||
return sub;
|
||||
});
|
||||
@@ -228,6 +235,16 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Standalone hostname substitution
|
||||
for (const [, h] of hostMap) {
|
||||
if (h.real.length >= 3) {
|
||||
result = result.replace(new RegExp('\\b' + esc(h.real) + '\\b', 'gi'), (matched) => {
|
||||
replacements.push({ original: matched, replaced: h.substitute, category: 'hostname', pattern: 'smart' });
|
||||
return h.substitute;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { text: result, replacements };
|
||||
|
||||
Reference in New Issue
Block a user