How to remove special charaters in shortId

Viewed 1415

I am using shortid nodejs package to create IDs in my project, i wanted to know if it can an ID could be generated without a special character?

1 Answers

According to the documentation provided by the author on npm, you can set the characters you want to generate id with, but the total of characters should be 64.

shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$@');

[A-Z][a-z][0-9] gives a total of 62, you have to use 2 special characters for it to make it work.

You must provide a string of all 64 unique characters. Order is not important.-- npm shortid docs.

Its the way the package is created, and you have to provide 2 special characters.

Related