Advanced
Matthew@matthew
24 days ago

question for devs: i'm currently using UUIDs as a URL slug but i want to do something shorter. Would it be reliable to use the first eight chars of the uuid and just route to the first match? for example ".com/c6850eaf-faf1-4408-9671-f1ca8a48a40b" becomes ".com/c6850eaf" or do you know a better option?

In reply to @matthew
24 days ago

this may be helpful to scale something to your need https://zelark.github.io/nano-id-cc/

In reply to @matthew
Brent Fitzgerald@bf
24 days ago

you want a true globally unique ID if you're not validating uniqueness some other way (like via DB constraint). you can encode using a larger character set to get a shorter ID. Base58 is a good option, removes visually ambiguous characters: example: '2d06b29b-7b47-4ba0-8325-419277d62a09' -> '6ZUv7sYDG4LALynrXCjMGL'

In reply to @matthew
David Furlong@df
24 days ago

slugs defined by users or generated. If theres a collision on generated, add -n where n is the smallest available number. In your case maybe an encoding of the original event url or slug

In reply to @matthew
olias@olias
24 days ago

next time i design a system with externally exposed ids, i plan to use stripe's pattern https://dev.to/stripe/designing-apis-for-humans-object-ids-3o5a