Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isValid is reseting characters to default #3

Open
nickistre opened this issue Nov 14, 2018 · 0 comments
Open

isValid is reseting characters to default #3

nickistre opened this issue Nov 14, 2018 · 0 comments

Comments

@nickistre
Copy link

I'm trying to use this package in a project, but I wanted to use lowercased letters instead, so I used the string "abcdefghijkmnpqrstuvwxyz23456789" instead (removing the characters "l10o"). I was using the isValid call to in a test to check that a field was being filled with a valid value, but apparently, isValid is resetting the characters to the original string and checking against that, failing the current isValid check and causing any further use of generate() to use the originally capitalized string.

Here is an example of what I'm seeing, starting node from the root of the project:

var shortid32 = require(".");
shortid32.characters("abcdefghijkmnpqrstuvwxyz23456789");
var id = shortid32.generate();
console.log(id); // Should return something like 'yhzz6ad9z'
var check = shortid32.isValid(id);
console.log(check); // Returns false!
console.log(shortid32.characters()); // Returns something like 'DPZNKTVGCAX9J5WUMFRYHE4LS236Q78B'!!
id = shortid32.generate();
console.log(id); // Returns something like 'VMRLUQ78K'!

I'll just leave this validity check out in my tests and just do a basic "is string" check, but just wanted to put a heads up on this very unexpected behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant