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';
|
import { generateRandomSubdomain } from 'src/engine/core-modules/domain-manager/utils/generate-random-subdomain';
|
||||||
|
|
||||||
describe('generateRandomSubdomain', () => {
|
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();
|
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', () => {
|
it('should generate different results on consecutive calls', () => {
|
||||||
|
|||||||
@ -1,71 +1,105 @@
|
|||||||
export const generateRandomSubdomain = () => {
|
export const generateRandomSubdomain = () => {
|
||||||
const prefixes = [
|
const prefixes = [
|
||||||
'cool',
|
'bold',
|
||||||
'smart',
|
'bouncy',
|
||||||
'fast',
|
|
||||||
'bright',
|
|
||||||
'shiny',
|
|
||||||
'happy',
|
|
||||||
'funny',
|
|
||||||
'clever',
|
|
||||||
'brave',
|
'brave',
|
||||||
'kind',
|
'bright',
|
||||||
'gentle',
|
|
||||||
'quick',
|
|
||||||
'sharp',
|
|
||||||
'calm',
|
'calm',
|
||||||
'silent',
|
'clever',
|
||||||
'lucky',
|
'colorful',
|
||||||
|
'cool',
|
||||||
|
'eager',
|
||||||
|
'fast',
|
||||||
'fierce',
|
'fierce',
|
||||||
'swift',
|
'funny',
|
||||||
|
'gentle',
|
||||||
|
'glad',
|
||||||
|
'graceful',
|
||||||
|
'happy',
|
||||||
|
'joyful',
|
||||||
|
'kind',
|
||||||
|
'lucky',
|
||||||
'mighty',
|
'mighty',
|
||||||
'noble',
|
'noble',
|
||||||
'bold',
|
'quick',
|
||||||
|
'sharp',
|
||||||
|
'shiny',
|
||||||
|
'silent',
|
||||||
|
'smart',
|
||||||
|
'swift',
|
||||||
'wise',
|
'wise',
|
||||||
'eager',
|
|
||||||
'joyful',
|
|
||||||
'glad',
|
|
||||||
'zany',
|
|
||||||
'witty',
|
'witty',
|
||||||
'bouncy',
|
'zany',
|
||||||
'graceful',
|
|
||||||
'colorful',
|
|
||||||
];
|
];
|
||||||
const suffixes = [
|
const suffixes = [
|
||||||
'raccoon',
|
'bear',
|
||||||
'panda',
|
'crocodile',
|
||||||
'whale',
|
|
||||||
'tiger',
|
|
||||||
'dolphin',
|
'dolphin',
|
||||||
'eagle',
|
'eagle',
|
||||||
'penguin',
|
'elephant',
|
||||||
'owl',
|
'falcon',
|
||||||
'fox',
|
'fox',
|
||||||
'wolf',
|
'giraffe',
|
||||||
'lion',
|
|
||||||
'bear',
|
|
||||||
'hawk',
|
'hawk',
|
||||||
|
'hedgehog',
|
||||||
|
'horse',
|
||||||
|
'kangaroo',
|
||||||
|
'koala',
|
||||||
|
'lion',
|
||||||
|
'lynx',
|
||||||
|
'monkey',
|
||||||
|
'moose',
|
||||||
|
'octopus',
|
||||||
|
'owl',
|
||||||
|
'panda',
|
||||||
|
'panther',
|
||||||
|
'penguin',
|
||||||
|
'rabbit',
|
||||||
|
'raccoon',
|
||||||
|
'seal',
|
||||||
'shark',
|
'shark',
|
||||||
'sparrow',
|
'sparrow',
|
||||||
'moose',
|
'tiger',
|
||||||
'lynx',
|
'whale',
|
||||||
'falcon',
|
'wolf',
|
||||||
'rabbit',
|
];
|
||||||
'hedgehog',
|
|
||||||
'monkey',
|
const colors = [
|
||||||
'horse',
|
'almond',
|
||||||
'koala',
|
'amber',
|
||||||
'kangaroo',
|
'azure',
|
||||||
'elephant',
|
'beige',
|
||||||
'giraffe',
|
'black',
|
||||||
'panther',
|
'blue',
|
||||||
'crocodile',
|
'brown',
|
||||||
'seal',
|
'crimson',
|
||||||
'octopus',
|
'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 randomPrefix = prefixes[Math.floor(Math.random() * prefixes.length)];
|
||||||
const randomSuffix = suffixes[Math.floor(Math.random() * suffixes.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