Open terinjokes opened 5 years ago
I really like this idea! Some positives:
_id
is sequential, hashids converts them into something which is much harder to reverse engineer. You'd need to guess the salt 👍 foo
will likely return an error, which means we can then just go and do a database lookup for that manual id.9007199254740991
works fine. Some negatives:
Thanks for your suggestion here @terinjokes! I think we'll look into implementing this on Jan 7th or Jan 8th!
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.
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.