Merged
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("-_", "+/") |
Member
There was a problem hiding this comment.
I noticed that in the base64 gem, the method tr has a bang in the if branch, but not in the else branch 🤔
Contributor
Author
There was a problem hiding this comment.
Interesting! I'll open a separate PR to fix that 🙂
nicolastemciuc
approved these changes
May 19, 2025
Member
nicolastemciuc
left a comment
There was a problem hiding this comment.
Looks good to me! Thanks! ❤️
It is not a runtime dependency yet we were still using it in `lib/webauthn/u2f_migrator.rb`.
That way we can avoid breaking changes. Let's change its namespace in the future when we decide to release a new major version.
54d025c to
db5bc9a
Compare
nicolastemciuc
approved these changes
May 23, 2025
This was referenced May 23, 2025
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fixes #422.
Details
This PR introduces the new
Encodersmodule 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 thebase64dependency. This logic was previously encapsulated inEncoderwhich now will just delegates encoding and decoding tasks to specific encoder classes defined in the newEncodersmodule - we are really just keeping it, just in case, for backward compatibility.The new
Encoderscontains classes forBase64Encoder,Base64UrlEncoder, andNullEncoderand alookupmethod to return the appropriate encoder class based on the encoding type.Finally, it also updates the different parts of the gem where the
base64gem was used.