Add shuffle algoritm for more diverse default email generation
parent
e5d9a6cf8c
commit
5690348137
|
@ -84,6 +84,20 @@ class Helper {
|
|||
|
||||
return footer
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuffle an array using the Durstenfeld shuffle algorithm
|
||||
* @param {Array} array
|
||||
* @returns {Array}
|
||||
*/
|
||||
|
||||
shuffleArray(array) {
|
||||
for (let i = array.length - 1; i >= 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
}
|
||||
return array
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Helper
|
||||
|
|
|
@ -14,7 +14,7 @@ router.get('/', (req, res, _next) => {
|
|||
title: `${config.http.branding[0]} | Your temporary Inbox`,
|
||||
username: randomWord(),
|
||||
purgeTime: purgeTime,
|
||||
domains: config.email.domains,
|
||||
domains: helper.shuffleArray(config.email.domains),
|
||||
branding: config.http.branding,
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue