jonschlinkert / randomatic

Easily generate random strings like passwords, with simple options for specifying a length and for using patterns of numeric, alpha-numeric, alphabetical, special or custom characters. (the original "generate-password")
https://github.com/jonschlinkert
MIT License
183 stars 25 forks source link

Exclude not working. #18

Closed kross50 closed 5 years ago

kross50 commented 5 years ago

Hi, love what you've done. Found a little issue in 3.1.0

Exclude defined: password = randomize('*', 10, { exclude: '0oOiIlL1$^()_{}[];\',.' });

Output: joPUbWOU21

Observations: Exclude not working as we can see that o and O that were specified to be excluded are being used. Also, in other tests of mine, I see (){} being used output as well.

My Temp Workaround: password = randomize('?', 10, {chars: 'abcdefghjkmnopqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ123456789~!@#&+-='});

doowb commented 5 years ago

Thanks for the issue. This does look like a bug and I think it's because the regex used to remove the characters is built by doing a naive string concatenation. If you or someone else has an idea on a fix, please feel free to submit a PR. If not, I'll try to get a fix done by this weekend.

ywpark1 commented 5 years ago

I would like to work on this!

doowb commented 5 years ago

Fixed in #19