mplanchard / cuid-rust

Rust implemention of CUID unique IDs
https://crates.io/crates/cuid
MIT License
91 stars 15 forks source link

cuid::is_cuid panics on empty strings #3

Closed DeppLearning closed 3 years ago

DeppLearning commented 3 years ago

Thanks for the crate. Using it for a while now but encountered this issue today.

Instead of a panic I was expecting the method to return false. If this isn't feasible then maybe document the behavior?

Example:

cuid::is_cuid("")

-> panicked at 'byte index 1 is out of bounds of'

mplanchard commented 3 years ago

Thanks for the report! I agree this should return false, and I’m happy to update it. I’m on vacation this week, but I’ll get to it as soon as possible

On Mon, Jul 26, 2021 at 8:32 PM DeppLearning @.***> wrote:

Thanks for the crate. Using it for a while now but encountered this issue today.

Instead of a panic I was expecting the method to return false. If this isn't feasible then maybe document the behavior?

Example:

cuid::is_cuid("")

-> panicked at 'byte index 1 is out of bounds of'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mplanchard/cuid-rust/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTQRYKWIAC2ZNLCHAL3V4LTZX5DVANCNFSM5BBE6TQQ .

mplanchard commented 3 years ago

Resolved with a4fca2f and released in version 1.1.0, along with some improvements to the is_cuid() and is_slug() functions. Thanks again for the report!