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

Use padding: false option over gsub #142

Merged
merged 1 commit into from
May 13, 2022
Merged

Use padding: false option over gsub #142

merged 1 commit into from
May 13, 2022

Conversation

daemonsy
Copy link
Contributor

@daemonsy daemonsy commented May 12, 2022

What's up?

I used the #to_param for my GIDs and it's awesome. Was reading the code and noticed a small improvement opportunity.

Since Ruby >= 2.3.0, Base64.urlsafe_encode64 accepts padding: false to exclude padding.

Base64.urlsafe_decode64 also works with strings with or without padding.

This PR removes the custom gsub in favor of using padding: false

The caveat is that this method will break for Ruby < 2.3

@byroot byroot merged commit 2150756 into rails:main May 13, 2022
@byroot
Copy link
Member

byroot commented May 13, 2022

Thanks.

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.

2 participants