-
Notifications
You must be signed in to change notification settings - Fork 60
Remove base64
dependency
#459
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
base: master
Are you sure you want to change the base?
Conversation
BREAKING CHANGE: The `STANDARD_ENCODING` const is now under `Encoders` instead of `Encoder` which may lead to undefined const errors if you are using this const for some reason.
…ment Let's add it to `Encoders.new` for backward compatibility.
13421f1
to
54d025c
Compare
data = data.ljust((data.length + 3) & ~3, "=") | ||
end | ||
|
||
data = data.tr("-_", "+/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that in the base64 gem, the method tr
has a bang in the if branch, but not in the else branch 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! I'll open a separate PR to fix that 🙂
Motivation
Fixes #422.
Details
This PR introduces the new
Encoders
module in order to encapsulate the logic of the different encoding methods into the same place and let us re-use this logic in across all the different parts of the gem which will in turn allow us to cleanly (and finally) remove thebase64
dependency. This logic was previously encapsulated inEncoder
which now will just delegates encoding and decoding tasks to specific encoder classes defined in the newEncoders
module - we are really just keeping it, just in case, for backward compatibility.The new
Encoders
contains classes forBase64Encoder
,Base64UrlEncoder
, andNullEncoder
and alookup
method to return the appropriate encoder class based on the encoding type.Finally, it also updates the different parts of the gem where the
base64
gem was used.