koddsson / link-shortener

🔗 It make the link shorter.
2 stars 2 forks source link

Proposal: utilize ES's _id field #27

Open terinjokes opened 5 years ago

terinjokes commented 5 years ago

Currently the URL shortener generates a random ID until it finds one that is unused. It might be better to use the unique _id field, along with a reverseable hash, like the hashids package.

keithamus commented 5 years ago

I really like this idea! Some positives:

Some negatives:

keithamus commented 5 years ago

Thanks for your suggestion here @terinjokes! I think we'll look into implementing this on Jan 7th or Jan 8th!

terinjokes commented 5 years ago

Unless I'm misreading the code here, I think the current implementation would also go beyond 2 characters pretty quickly: if it can't insert with the random id it chooses, it will append a new random character and try again.

To farther reduce conflicts, it might be worth considering putting manually generated URLs on another path, eg: /m/foo. Sure it makes them longer, but manual tends to be composed of words anyways.