From 1b004ba0db2b8e4e0a6b3362dd7681e0c642cab0 Mon Sep 17 00:00:00 2001 From: Joao Fernandes Date: Thu, 2 Sep 2021 16:57:26 +0100 Subject: [PATCH] [ruby/base64] Simplify Thanks @nobu! https://github.com/ruby/base64/commit/39e22efa2b --- lib/base64.rb | 8 +------- 1 file changed, 1 insertion(+), 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