Generate more random subdomains (#11249)
Sorted the 2 existing lists + added a new colors list to generate the random subdomain to have less collision <img width="368" alt="Screenshot 2025-03-27 at 19 25 28" src="https://github.com/user-attachments/assets/6d6d27f1-134b-4ae7-88a6-4af506115317" />
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
import { generateRandomSubdomain } from 'src/engine/core-modules/domain-manager/utils/generate-random-subdomain';
|
||||
|
||||
describe('generateRandomSubdomain', () => {
|
||||
it('should return a string in the format "prefix-suffix"', () => {
|
||||
it('should return a string in the format "prefix-color-suffix"', () => {
|
||||
const result = generateRandomSubdomain();
|
||||
|
||||
expect(result).toMatch(/^[a-z]+-[a-z]+$/);
|
||||
expect(result).toMatch(/^[a-z]+-[a-z]+-[a-z]+$/);
|
||||
});
|
||||
|
||||
it('should generate different results on consecutive calls', () => {
|
||||
|
||||
@ -1,71 +1,105 @@
|
||||
export const generateRandomSubdomain = () => {
|
||||
const prefixes = [
|
||||
'cool',
|
||||
'smart',
|
||||
'fast',
|
||||
'bright',
|
||||
'shiny',
|
||||
'happy',
|
||||
'funny',
|
||||
'clever',
|
||||
'bold',
|
||||
'bouncy',
|
||||
'brave',
|
||||
'kind',
|
||||
'gentle',
|
||||
'quick',
|
||||
'sharp',
|
||||
'bright',
|
||||
'calm',
|
||||
'silent',
|
||||
'lucky',
|
||||
'clever',
|
||||
'colorful',
|
||||
'cool',
|
||||
'eager',
|
||||
'fast',
|
||||
'fierce',
|
||||
'swift',
|
||||
'funny',
|
||||
'gentle',
|
||||
'glad',
|
||||
'graceful',
|
||||
'happy',
|
||||
'joyful',
|
||||
'kind',
|
||||
'lucky',
|
||||
'mighty',
|
||||
'noble',
|
||||
'bold',
|
||||
'quick',
|
||||
'sharp',
|
||||
'shiny',
|
||||
'silent',
|
||||
'smart',
|
||||
'swift',
|
||||
'wise',
|
||||
'eager',
|
||||
'joyful',
|
||||
'glad',
|
||||
'zany',
|
||||
'witty',
|
||||
'bouncy',
|
||||
'graceful',
|
||||
'colorful',
|
||||
'zany',
|
||||
];
|
||||
const suffixes = [
|
||||
'raccoon',
|
||||
'panda',
|
||||
'whale',
|
||||
'tiger',
|
||||
'bear',
|
||||
'crocodile',
|
||||
'dolphin',
|
||||
'eagle',
|
||||
'penguin',
|
||||
'owl',
|
||||
'elephant',
|
||||
'falcon',
|
||||
'fox',
|
||||
'wolf',
|
||||
'lion',
|
||||
'bear',
|
||||
'giraffe',
|
||||
'hawk',
|
||||
'hedgehog',
|
||||
'horse',
|
||||
'kangaroo',
|
||||
'koala',
|
||||
'lion',
|
||||
'lynx',
|
||||
'monkey',
|
||||
'moose',
|
||||
'octopus',
|
||||
'owl',
|
||||
'panda',
|
||||
'panther',
|
||||
'penguin',
|
||||
'rabbit',
|
||||
'raccoon',
|
||||
'seal',
|
||||
'shark',
|
||||
'sparrow',
|
||||
'moose',
|
||||
'lynx',
|
||||
'falcon',
|
||||
'rabbit',
|
||||
'hedgehog',
|
||||
'monkey',
|
||||
'horse',
|
||||
'koala',
|
||||
'kangaroo',
|
||||
'elephant',
|
||||
'giraffe',
|
||||
'panther',
|
||||
'crocodile',
|
||||
'seal',
|
||||
'octopus',
|
||||
'tiger',
|
||||
'whale',
|
||||
'wolf',
|
||||
];
|
||||
|
||||
const colors = [
|
||||
'almond',
|
||||
'amber',
|
||||
'azure',
|
||||
'beige',
|
||||
'black',
|
||||
'blue',
|
||||
'brown',
|
||||
'crimson',
|
||||
'cyan',
|
||||
'gold',
|
||||
'gray',
|
||||
'green',
|
||||
'indigo',
|
||||
'lime',
|
||||
'magenta',
|
||||
'maroon',
|
||||
'mint',
|
||||
'mustard',
|
||||
'orange',
|
||||
'peach',
|
||||
'pink',
|
||||
'purple',
|
||||
'red',
|
||||
'salmon',
|
||||
'silver',
|
||||
'teal',
|
||||
'turquoise',
|
||||
'violet',
|
||||
'white',
|
||||
'yellow',
|
||||
];
|
||||
|
||||
const randomPrefix = prefixes[Math.floor(Math.random() * prefixes.length)];
|
||||
const randomSuffix = suffixes[Math.floor(Math.random() * suffixes.length)];
|
||||
const randomColor = colors[Math.floor(Math.random() * colors.length)];
|
||||
|
||||
return `${randomPrefix}-${randomSuffix}`;
|
||||
return `${randomPrefix}-${randomColor}-${randomSuffix}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user