Skip to content

Use padding: false option over gsub#142

Merged
byroot merged 1 commit intorails:mainfrom
daemonsy:main
May 13, 2022
Merged

Use padding: false option over gsub#142
byroot merged 1 commit intorails:mainfrom
daemonsy:main

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