supabase-community/copycat

Support slugs?

zomars opened this issue · 3 comments

I see that your username function may generate usernames with dots in them. In our use case we need to generate username with only alphanumeric characters and maybe dashes and underscores.

Hey @zomars, thanks for the request. I'm going back and forth on whether to add an option for copycat.username() for this.

What do you think about just using other copycat functions on your side to put this together? e.g.

import { copycat as c } from '@snaplet/copycat'

const username = x => `${c.firstName(x)}-${c.lastName(x)}${c.int(x, { min: 2, max: 99 })}`

or for dashes or underscores:

import { copycat as c } from '@snaplet/copycat'

const username = x => [c.firstName(x), c.oneOf(x, ['_', '-']), c.lastName(x), c.int(x, { min: 2, max: 99 })].join('')

This can work for now. Thanks for the insights 🙏🏽

Awesome, thanks @zomars :) Closing for now then.