Spaces:
Build error
Build error
File size: 892 Bytes
ef73937 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import { nanoid } from 'nanoid';
import { nanoidDictionary } from 'nanoid-dictionary';
export function generateId(length = 21): string {
return nanoid(length);
}
export function generateVerificationCode(): string {
const dictionary = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'; // Remove confusing chars: I, O, 0, 1
let code = '';
for (let i = 0; i < 6; i++) {
code += dictionary[Math.floor(Math.random() * dictionary.length)];
}
return code;
}
export function generateSecureToken(length = 32): string {
return nanoid(length);
}
export function slugify(text: string): string {
return text
.toLowerCase()
.trim()
.replace(/[^\w\s-]/g, '')
.replace(/[\s_-]+/g, '-')
.replace(/^-+|-+$/g, '');
}
export function generateChannelSlug(name: string): string {
const base = slugify(name);
const suffix = nanoid(6).toLowerCase();
return `${base}-${suffix}`;
} |