[ruby/base64] Simplify
Thanks @nobu! https://github.com/ruby/base64/commit/39e22efa2b
This commit is contained in:
parent
05a28ce5b1
commit
1b004ba0db
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user