summaryrefslogtreecommitdiff
path: root/lib/base64.rb
diff options
context:
space:
mode:
authorJoao Fernandes <joao@hopin.to>2021-09-02 16:57:26 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-09-27 15:23:12 +0900
commit1b004ba0db2b8e4e0a6b3362dd7681e0c642cab0 (patch)
treeb98f065dc574f8d0766965589f315652166e3db0 /lib/base64.rb
parent05a28ce5b11d0e0ca48bae799ef65e9657dc4f6a (diff)
downloadruby-1b004ba0db2b8e4e0a6b3362dd7681e0c642cab0.tar.gz
[ruby/base64] Simplify
Thanks @nobu! https://github.com/ruby/base64/commit/39e22efa2b
Diffstat (limited to 'lib/base64.rb')
-rw-r--r--lib/base64.rb8
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/base64.rb b/lib/base64.rb
index 6b049982cf..de1e8c0e55 100644
--- a/lib/base64.rb
+++ b/lib/base64.rb
@@ -82,13 +82,7 @@ module Base64
# You can remove the padding by setting +padding+ as false.
def urlsafe_encode64(bin, padding: true)
str = strict_encode64(bin)
- unless padding
- if str.end_with?("==")
- str.delete_suffix!("==")
- elsif str.end_with?("=")
- str.chop!
- end
- end
+ str.chomp!("==") or str.chomp!("=") unless padding
str.tr!("+/", "-_")
str
end