New email address suggestion as an example when to consequent entries are the same
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- tooling
Direzione di ricerca
Start at the generateMail() entry point in the supplied script and review the Iteration and naming-convention branches first. No file or test is named in the issue; completion should be confirmed by checking that consecutive collision iterations produce the intended email address examples for B, P, BP, and PB conventions.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
// customer email naming convention
//
// This script generates an email address based on:
// - the configured name convention (B / P / BP / PB)
// - the HelloID-provided Iteration value (used for collision handling)
//
// Iteration logic (provided by HelloID):
// - Iteration 0 : first letter of first name (e.g. "j.")
// - Iteration 1 : initials with dots (e.g. "h.c.")
// - Iteration 2 : full first name (e.g. "janine.")
// - Iteration >=3: fallback to first letter of first name + numeric suffix
//
// Numeric suffix rules:
// - No suffix for Iteration 0, 1 and 2
// - Iteration 3 -> suffix "1"
// - Iteration 4 -> suffix "2"
// - Iteration 5 -> suffix "3"
// - etc.
//
// Naming conventions (examples):
//
// B (Birth name)
// Iteration 0 : [email protected]
// Iteration 1 : [email protected]
// Iteration 2 : [email protected]
// Iteration 3 : [email protected]
//
// P (Partner name)
// Iteration 0 : [email protected]
// Iteration 1 : [email protected]
// Iteration 2 : [email protected]
// Iteration 3 : [email protected]
//
// BP (Birth-Partner)
// Iteration 0 : [email protected]
// Iteration 1 : [email protected]
// Iteration 2 : [email protected]
// Iteration 3 : [email protected]
//
// PB (Partner-Birth)
// Iteration 0 : [email protected]
// Iteration 1 : [email protected]
// Iteration 2 : [email protected]
// Iteration 3 : [email protected]
//
// Normalization rules:
// - Output is lowercase
// - Diacritical characters are removed (e.g. é -> e)
// - Spaces are converted to dots (e.g. "Abdul Mohammed" -> "abdul.mohammed")
// - Only [0-9a-zA-Z . - _] are allowed; other characters are removed
// - No double dots are allowed (".." -> ".")
// - No leading or trailing dots
// - The local-part is truncated to fit within limits before appending suffix and domain
//
// Testing tip:
// - You can temporarily hardcode Iteration to validate outputs, for example:
Iteration = 0
function generateMail() {
const domain = 'customer.nl';
let initials = Person.Name.Initials;
let nickName = Person.Name.NickName;
let middleName = Person.Name.FamilyNamePrefix;
let lastName = Person.Name.FamilyName;
let middleNamePartner = Person.Name.FamilyNamePartnerPrefix;
let lastNamePartner = Person.Name.FamilyNamePartner;
let convention = Person.Name.Convention;
let mailNickName = '';
let initialsWithoutDots = (initials || '').replace(/[^a-zA-Z]/g, '').toLowerCase();
let firstLetterNickName = nickName.substring(0, 1).toLowerCase();
let suffix = '';
if (initialsWithoutDots !== firstLetterNickName && initialsWithoutDots != '') {
// Build numeric suffix for Iteration >= 3: 1,2,3... (variation with initials)
if (Iteration >= 3) {
suffix = (Iteration - 2).toString();
}
// Build the "given name" prefix based on iteration (first letter nickname != initials (without dots))
switch (Iteration) {
case 0:
// Iteration 0: first letter of first name
mailNickName = nickName.substring(0, 1) + '.';
break;
case 1:
// Iteration 1: initials with dots (letters only)
mailNickName = initials
.replace(/[^a-zA-Z]/g, '') // keep letters only
.split('')
.join('.') + '.';
break;
case 2:
// Iteration 2: full first name
mailNickName = nickName + '.';
break;
default:
// Iteration >= 3: fallback to first letter of first name
mailNickName = nickName.substring(0, 1) + '.';
break;
}
} else {
// Build numeric suffix for Iteration >= 3: 1,2... (variation without initials)
if (Iteration >= 2) {
suffix = (Iteration - 1).toString();
}
// Build the "given name" prefix based on iteration (first letter nickname = initials (without dots))
switch (Iteration) {
case 0:
// Iteration 0: first letter of first name
mailNickName = nickName.substring(0, 1) + '.';
break;
case 1:
// Iteration 2: full first name
mailNickName = nickName + '.';
break;
default:
// Iteration >= 3: fallback to first letter of first name
mailNickName = nickName.substring(0, 1) + '.';
break;
}
}
// Append birth/partner name parts based on convention
switch (convention) {
case "BP":
if (typeof middleName !== 'undefined' && middleName) {
mailNickName = mailNickName + middleName.replace(/ /g, '.') + '.';
}
mailNickName = mailNickName + lastName;
mailNickName = mailNickName + '-';
if (typeof middleNamePartner !== 'undefined' && middleNamePartner) {
mailNickName = mailNickName + ' ' + middleNamePartner.replace(/ /g, '.') + '.';
}
mailNickName = mailNickName + lastNamePartner;
break;
case "PB":
if (typeof middleNamePartner !== 'undefined' && middleNamePartner) {
mailNickName = mailNickName + ' ' + middleNamePartner.replace(/ /g, '.') + '.';
}
mailNickName = mailNickName + lastNamePartner;
mailNickName = mailNickName + '-';
if (typeof middleName !== 'undefined' && middleName) {
mailNickName = mailNickName + middleName.replace(/ /g, '.') + '.';
}
mailNickName = mailNickName + lastName;
break;
case "P":
if (typeof middleNamePartner !== 'undefined' && middleNamePartner) {
mailNickName = mailNickName + middleNamePartner.replace(/ /g, '.') + '.';
}
mailNickName = mailNickName + lastNamePartner;
break;
case "B":
default:
if (typeof middleName !== 'undefined' && middleName) {
mailNickName = mailNickName + middleName.replace(/ /g, '.') + '.';
}
mailNickName = mailNickName + lastName;
break;
}
// Remove whitespace at start/end
mailNickName = mailNickName.trim();
// Lowercase
mailNickName = mailNickName.toLowerCase();
// Remove diacritical characters (e.g. é -> e)
mailNickName = deleteDiacriticalMarks(mailNickName);
// Convert spaces to dots so multi-part names remain readable
mailNickName = mailNickName.replace(/\s+/g, '.');
// Remove characters outside the allowed set
mailNickName = mailNickName.replace(/[^0-9a-zA-Z.\-_]/g, '');
// Normalize dots: no "..", no leading/trailing "."
mailNickName = mailNickName
.replace(/\.{2,}/g, '.')
.replace(/^\.|\.$/g, '');
// Truncate local-part so suffix + "@domain" still fits within limits
const maxAttributeLength = (256 - suffix.length - domain.length);
mailNickName = mailNickName.substring(0, maxAttributeLength);
// Append suffix (if any) and domain
mailNickName = mailNickName + suffix;
return mailNickName + '@' + domain;
}
generateMail();
- Lingua principale
- JavaScript
- Stelle
- 3
- Fork
- 1
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Tools4everBV/HelloID-Lib-Prov-HelperFunctions
-
Context.InConditions in complex mappingForse di nuovo libera @Rick-Jongbloed l’ha presa 240 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
Tools4everBV/HelloID-Lib-Prov-HelperFunctions#18 · 2 commenti · 1 assegnatario ·
Tutte le issue di Tools4everBV/HelloID-Lib-Prov-HelperFunctions
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openlibhums/janeway#5604 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] Generic OSC does not initialize OSC client on startup when "Listen for Feedback" is disabledAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
area/statement-execution TS conversion
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
scylladb/nodejs-rs-driver#584 ·
I maintainer di solito rispondono entro 2 giorni
-
新讀者走讀回報,照著一篇文章實際操作Apertadocumentation good first issue help wanted
Difficoltà 1/5 1-3 ore Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
I maintainer di solito rispondono entro 3 giorni