-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Decoding the same string outputs different results between 1.2.8 and 2.0.0 #75
Comments
Thanks for the test cases, that's helpful. So to summarize: For invalid inputs, v1.2.8 returns a number whereas v2.0.0 returns Thus I'd recommend you adjust your test cases to reflect this new, arguably more correct behavior. I had a brief look at the PR linked above, but lack sufficient context to assess the impact for your application - please let me know if that works for you. (FWIW, if we ever get around to it, v3.0 will probably be more strict, validating inputs to avoid such confusion - see #57.) |
That makes sense, I'll update our code. |
@FND could you maybe document this behavior? |
I'm afraid it appears that behavior for invalid inputs is inconsistent: So documenting this isn't straightforward - that's unfortunate, of course, but I'd rather expend energy on fixing the underlying issues for v3.0 (see above). |
ah, oops. Ok, then hopefully everything will be ok and people will find more info in the issue tracker. Thanks a lot for your work on this lib! |
I'm glad it's proving useful. (For my part, I was mostly moving existing code around, building on Andrew's original work.) Since you're one of the few vocal users: Would migrating to the/a new API with strict input validation be a realistic option for you? From my perspective, that should be pretty straightforward and quick, but I don't wanna presume... |
I don't have a strong opinion on this, of course we'd like to keep the current API (or actually the legacy one) because it works well for us. That being said, if there is a new API and some upgrade instructions, then no problem. I did not switch to the new API yet because it requires us to pass the character set to import base62 from 'base62/lib/custom';
const charset = base62.indexCharset(
'~9876543210ABCDEFGHIJKLMNOPQRSTU$#@%!abcdefghijklmnopqrstuvw-='
);
return {
decode: (data) => base62.decode(data, charset),
encode: (data) => base62.encode(data, charset),
}; We use this lib to encode/decode auth tokens with a Django backend (hence the need for a custom character set). |
That's helpful feedback, thank you! |
Hi,
one of our test cases caught what looks like a regression when trying to upgrade to
2.0.0
.Here is a snippet extracted from our app:
Version
1.2.8
outputs-1.1412490322742814e+34
, see: https://runkit.com/embed/t6myhreeij3jVersion
2.0.0
(latest) outputsNaN
, see: https://runkit.com/embed/szbz01t0km52The text was updated successfully, but these errors were encountered: