Skip to content

Commit 39e22ef

Browse files
committed
Simplify
Thanks @nobu!
1 parent 544e0c2 commit 39e22ef

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

lib/base64.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,7 @@ def strict_decode64(str)
8282
# You can remove the padding by setting +padding+ as false.
8383
def urlsafe_encode64(bin, padding: true)
8484
str = strict_encode64(bin)
85-
unless padding
86-
if str.end_with?("==")
87-
str.delete_suffix!("==")
88-
elsif str.end_with?("=")
89-
str.chop!
90-
end
91-
end
85+
str.chomp!("==") or str.chomp!("=") unless padding
9286
str.tr!("+/", "-_")
9387
str
9488
end

0 commit comments

Comments
 (0)