mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
05a28ce5b1
commit
1b004ba0db
1 changed files with 1 additions and 7 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue