oculus42 / short-uuid

Translate standard UUIDs into shorter formats and back.
MIT License
450 stars 13 forks source link

Patch: ConsistentLength for short.generate() #51

Closed thadeucity closed 3 years ago

thadeucity commented 3 years ago

When using the default value for consistentLength as True, the original generate would not return consistent length when you initiate it without a custom alphabet, because it would skip the instantiation of these parameters.

To solve that I started the shortenUUID function with default paddingParams. So it would use base params when a custom alphabet is not provided.

This patch should not cause any problems for users that already have been using the new 4.0.1 version.

oculus42 commented 3 years ago

Crud. Good catch. I'm going to fix it differently, though, as I'm already storing the generate which should world correctly.

Will add additional tests for the generate length.

oculus42 commented 3 years ago

Resolved as of v4.0.3. Great catch!

oculus42 commented 3 years ago

As a follow-up feature, I will add a max length to the translators so it is an easily accessed value.