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

Fix u64 overflow when decoding #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

Racum
Copy link

@Racum Racum commented Dec 8, 2024

I have a scenario where I need to test an ID not knowing before hand if is a valid Sqid or not, and, in some cases when an ID looks valid, but results in elements bigger than the maximum u64 value, the decode() function panics! For example, with the ID 0J4AEXRN106Z0.

To fix this I made to_number() return an Option<u64> (instead of just u64), and only push the value on decode() in case of Some().

By the way, I’m adding support to Sqids to an upcoming version of my ID parser/debug CLI tool, have a look: https://github.com/racum/uuinfo

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

Successfully merging this pull request may close these issues.

1 participant