Skip to content

isValid is reseting characters to default #3

@nickistre

Description

@nickistre

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions